i am attempting to launch an intent to open a link to the android market.
android manifest portion looks like this:
<activity android:name="com.surreall.sixdice.Start" android:label="Six Dice" android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity>
launching the intent looks like:
public void onClick(View v) { String PublisherID = "pub:surreallgames"; Uri marketUri = Uri.parse("market://search?q="+PublisherID); Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri); startActivity(marketIntent); }
logcat output:
06-17 17:38:47.393: E/AndroidRuntime(476): FATAL EXCEPTION: main 06-17 17:38:47.393: E/AndroidRuntime(476): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=market://search?q=pub:surreallgames } 06-17 17:38:47.393: E/AndroidRuntime(476): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409) 06-17 17:38:47.393: E/AndroidRuntime(476): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379) 06-17 17:38:47.393: E/AndroidRuntime(476): at android.app.Activity.startActivityForResult(Activity.java:2827) 06-17 17:38:47.393: E/AndroidRuntime(476): at android.app.Activity.startActivity(Activity.java:2933) 06-17 17:38:47.393: E/AndroidRuntime(476): at com.surreall.sixdice.Start$9.onClick(Start.java:265) 06-17 17:38:47.393: E/AndroidRuntime(476): at android.view.View.performClick(View.java:2485) 06-17 17:38:47.393: E/AndroidRuntime(476): at android.view.View$PerformClick.run(View.java:9080) 06-17 17:38:47.393: E/AndroidRuntime(476): at android.os.Handler.handleCallback(Handler.java:587) 06-17 17:38:47.393: E/AndroidRuntime(476): at android.os.Handler.dispatchMessage(Handler.java:92) 06-17 17:38:47.393: E/AndroidRuntime(476): at android.os.Looper.loop(Looper.java:123) 06-17 17:38:47.393: E/AndroidRuntime(476): at android.app.ActivityThread.main(ActivityThread.java:3683) 06-17 17:38:47.393: E/AndroidRuntime(476): at java.lang.reflect.Method.invokeNative(Native Method) 06-17 17:38:47.393: E/AndroidRuntime(476): at java.lang.reflect.Method.invoke(Method.java:507) 06-17 17:38:47.393: E/AndroidRuntime(476): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 06-17 17:38:47.393: E/AndroidRuntime(476): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 06-17 17:38:47.393: E/AndroidRuntime(476): at dalvik.system.NativeStart.main(Native Method)
To start an activity, use the method startActivity(intent) . This method is defined on the Context object which Activity extends. The following code demonstrates how you can start another activity via an intent. # Start the activity connect to the # specified class Intent i = new Intent(this, ActivityTwo.
You see no activity found to handle intent when you attempt to launch an intent either to open a link or to access an app component. It's an error message that is caused because the device is not an official android, Google Play is not supported, or it's a rooted device.
An Intent is a messaging object you can use to request an action from another app component. Although intents facilitate communication between components in several ways, there are three fundamental use cases: Starting an activity. An Activity represents a single screen in an app.
You are running this code on an Android environment that lacks the Google Play Store, such as an emulator, Kindle Fire, etc.
If you are encountering this on an emulator, test this code path on a device that has the Play Store.
If you are encountering this on some piece of hardware that lacks the Play Store, or if you are planning on distributing your app to devices that lack the Play Store, either handle the exception or use PackageManager
and resolveActivity()
to determine if your Intent
will succeed before calling startActivity()
.
if(intent.resolveActivity(getPackageManager()) != null) startActivityForResult(intent, 0); else ...
You can use Intent.createChooser() method to safely launch the Intent. If no application exists that can handle your intent, a dialog will be displayed telling the user just that. If however Google Play Store is installed, the user can that choose to "open" the intent in Play Store.
startActivity(Intent.createChooser(marketIntent, "dialogTitle"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With