Aadithya
Aadithya

Reputation: 189

Exception when open Android N shortcuts

I am trying to implement Android N shortcuts but it crashes with an exception android.content.ActivityNotFoundException: Shortcut could not be started. I believe its because I am not giving the correct targetPackageName in shortcuts.xml

I am not really sure what it should be pointing to if the application itself is in a different module and the activity I am trying to start is in a different module.

Any help is appreciated.

Upvotes: 2

Views: 491

Answers (2)

tmtrademark
tmtrademark

Reputation: 974

I had a similar problem recently. For me, the issue was that the Activity I was trying to launch only had an intent-filter for the LAUNCHER category. Once I created a separate intent filter that had category DEFAULT (ie, category android:name="android.intent.category.DEFAULT"), everything worked fine.

Note that if you're trying to use activities from different modules, it may be more flexible to use implicit intents. While your original approach will still work just fine, you may want to consider moving to using action constants instead of referring to the package name.

If that doesn't fix your problem, can you post your manifest and your shortcuts.xml?

Upvotes: 1

Mehul Jain
Mehul Jain

Reputation: 26

Be sure TargetPackageName is Correct. Use package name where activity exist.

Use ActivityName like this:

android:targetClass="com.example.logs.ExampleActivity"

Use Package like this:

android:targetPackage="com.example.logs"

I Hope this works!!!

Upvotes: 0

Related Questions