Good afternoon, guys.
I need to create a service-type APP with no icon or any trace of it running.
I've been able to hide everything I need and everything works fine.
However, I'm using BroadcastReceiver to load the app automatically at OS boot. And when this occurs, the APP stops because it does not find an Activity to load.
This only occurs when I've hidden the icon. Without hiding the icon, everything normal.
What am I doing wrong?
I'm hiding with:
PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName(this, MainActivity.class);
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
And the excerpts from BroadCast:
Manifest:
<receiver android:name="simpress.mobileinfo.MainActivity$MyBroadCastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
Broadcast receiver class: public static class MyBroadCastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
Intent i = new Intent(context, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}