SecurityException: Permission Denial requires null
I would like to launch the market from a preference screen but when I try to do this I obain a java.lang.SecurityException: Permission Denial: starting Intent { cmp=com.action.test/.ui开发者_如何学Python.activities.Test } from ProcessRecord{44db1300 3697:com.pippo.pluto/10067} (pid=3697, uid=10067) requires null. This is my code:
startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("market://search?q=pname:com.action.test")));
what am I doing wrong?
Thanks in advance Tobia
I did the following:
private class SupportDevListener implements OnPreferenceClickListener
{
@Override
public boolean onPreferenceClick(Preference preference)
{
try
{
Intent launchIntent = new Intent(Intent.ACTION_VIEW);
launchIntent.setData(Uri.parse(getString(R.string.market_search_url)));
startActivity(launchIntent);
}
catch (ActivityNotFoundException e)
{
Toast.makeText(AppSwipePreferences.this, R.string.error_launching_app, Toast.LENGTH_SHORT).show();
}
return true;
}
}
My R.string.market_search_url is defined as: market://search?q=magouyaware
I chose to put it in a try block because there are some Android phones that do not have the Android Market (they are not Google Experience devices). If the Market app can't be found then a toast message is displayed telling the user that the application couldn't be found.
Hope this helps...
精彩评论