-1

I hava a question about Android Receiver. I'm possible to change System app. B is the first app, when user turns on the power. But the problem is when user chooses FACTORY Mode(like setting language, google id...), B App has to be started finishing A App setting. That's why use android:enabled="false"and A App trigger B app. But not working.

I think "android.intent.action.BOOT_COMPLETED" send just one time after booting, so after changing enable receiver B app, it's not working. Is it right? Please can you give me some advise?

A App

PackageManager pm = getPackageManager();
ComponentName compName = new ComponentName("com.test.myapp", "com.test.myapp.receiver");
pm.setComponentEnabledSetting(compName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0);

B App AndoidManifest.xml

<receiver 
    android:name="com.test.myapp.receiver"
    android:enabled="false">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
    </intent-filter>
</receiver>

B App

public void onReceive(Context context, Intent intent) {
    if(Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())){
       Intent startMainActivityIntent = new Intent(context, new.class);
       startMainActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
       context.startActivity(startMainActivityIntent);
}
Mattia Maestrini
  • 30,486
  • 15
  • 81
  • 89
user3796216
  • 29
  • 1
  • 5
  • You can use default method `registerReceiver()` & `deregisterReceiver`. For more info see this : http://stackoverflow.com/questions/4134203/how-to-use-registerreceiver-method – uniruddh Apr 20 '15 at 07:34

1 Answers1

0

Why don't you just start app B from app A directly? Yes, boot completed triggered only once. But you can start app B without any receivers, look here for example

Community
  • 1
  • 1
Raiv
  • 5,463
  • 1
  • 31
  • 50