Hide the APP icon

Asked

Viewed 641 times

0

Good afternoon, you guys.

I need to create a service type APP, no icon or any trace of it running.

I’ve managed to hide everything I need and everything works fine.

However, I am using Broadcastreceiver to automatically load the app on OS boot. And when this occurs, the APP stops because it can’t find an Activity to load.

This only occurs when I hid 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:

Manifesto:

    <receiver android:name="simpress.mobileinfo.MainActivity$MyBroadCastReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>

Class broadcast receiver: 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);
        }
    }
}
  • 1

    creates a .png Transparent.

  • If the application is not to have a Activity (does not need to interact with the user) so the Broadcastreceiver should launch a service and not a Activity.

  • Nice, this I had not even called me. So my Main will not extend Activity, but should extend a service class. What would be this class?

  • See the guide on documentation

  • Hello friend you managed to make the Broadcastreceiver work without an Activity?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.