如何在我的Android应用程序中禁用另一个应用程序广播接收器?

时间:2014-02-05 14:00:33

标签: android broadcastreceiver

我需要通过我的应用程序禁用我手机中所有已安装应用程序的拨出广播接收器。我试过,但我没有得到它。请帮帮我

这是我的代码

PackageManager packageManager = getPackageManager();

    List<String> startupApps = new ArrayList<String>();
            final Intent intent = new Intent("android.intent.action.NEW_OUTGOING_CALL");
            final List<ResolveInfo> activities = packageManager.queryBroadcastReceivers(intent, 0);
            for (ResolveInfo resolveInfo : activities) {
                ActivityInfo activityInfo = resolveInfo.activityInfo;
                if (activityInfo != null)
                    startupApps.add(activityInfo.name);
            }
            Log.e("receivers",startupApps.toString());

            for(int i=0;i<startupApps.size();i++)
            {
             if(!("com.example.customcalling.GetOutgoingNUmber1").equals(startupApps.get(i)))
             {
              String newreceivers=startupApps.get(i);
              Log.i("newReceivers", newreceivers);
              ComponentName receiver = new ComponentName("com.isodroid.fsci.controller.receiver","com.isodroid.fsci.controller.receiver.OutgoingCallReceiver");
        pm.setComponentEnabledSetting(receiver,
          PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
          PackageManager.DONT_KILL_APP);
             }
            }

    startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:"
      + phonenumber)));

1 个答案:

答案 0 :(得分:4)

这是不可能的。您无权禁用(或启用)其他应用的组件。