【问题标题】:SecurityException: Permission Denial requires nullSecurityException:权限拒绝需要 null
【发布时间】:2010-05-20 19:06:36
【问题描述】:

我想从首选项屏幕启动市场,但是当我尝试这样做时,我得到一个 java.lang.SecurityException: Permission Denial: starting Intent { cmp=com.action.test/.ui.activities.Test } 来自 ProcessRecord{44db1300 3697:com.pippo.pluto/10067} (pid=3697, uid=10067) 需要 null。 这是我的代码:

startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("market://search?q=pname:com.action.test")));

我做错了什么?

提前致谢 托比亚

【问题讨论】:

    标签: android android-activity android-intent


    【解决方案1】:

    我做了以下事情:

    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;
        }
    }
    

    我的 R.string.market_search_url 定义为:market://search?q=magouyaware

    我选择将它放在 try 块中,因为有些 Android 手机没有 Android Market(它们不是 Google Experience 设备)。如果找不到 Market 应用程序,则会显示一条 toast 消息,告诉用户找不到该应用程序。

    希望这会有所帮助...

    【讨论】:

      猜你喜欢
      • 2018-05-23
      • 2011-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-22
      • 2014-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多