barkside
barkside

Reputation: 3971

Permission Denial with ACTION_PICK_ACTIVITY

A user has reported the following Force Close:

java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.PICK_ACTIVITY cmp=com.android.settings/.ActivityPicker (has extras) } from ProcessRecord{43ab9d40 15868:com.barkside.music/u0a10113} (pid=15868, uid=10113) requires huawei.android.permission.HW_SIGNATURE_OR_SYSTEM at android.os.Parcel.readException(Parcel.java:1434) at android.os.Parcel.readException(Parcel.java:1388) at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1985) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1419) at android.app.Activity.startActivityForResult(Activity.java:3449) at android.app.Activity.startActivityForResult(Activity.java:3388) at com.barkside.music.PlayInActivity.onAddApp(Unknown Source)

This occurs when I attempt to startActivity using the ACTION_PICK_ACTIVITY .

The only report I have for this is for Huawei Ascend Mate 2 running 4.3.

So Huawei seem to have locked down this for use by System apps only. Is there anyway round this without having to implement my own pick activity listing installed apps to pick from?

Edit: Added code:

Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
Intent pickIntent = new Intent(Intent.ACTION_PICK_ACTIVITY);
pickIntent.putExtra(Intent.EXTRA_TITLE, "Pick App to Play in");
pickIntent.putExtra(Intent.EXTRA_INTENT, mainIntent);
this.startActivityForResult(pickIntent, REQUEST_PICK_APPLICATION);

Upvotes: 3

Views: 1316

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007584

So I tried the createChooser, and of course it actually sent the intent to the application chosen by the user. What I wanted is for the class of the activity to be returned to me in onActivityResult. Can ACTION_CHOOSER do this somehow?

No. For that, particularly given your problems with ACTION_PICK_ACTIVITY, you are going to have to roll your own UI, using PackageManager and queryIntentActivities(). It's reminiscent of writing a home screen launcher, as in my Launchalot sample.

Upvotes: 0

Related Questions