user1166635
user1166635

Reputation: 2801

How to load my application automatically after loading Android OS?

Is there any way how can I load my application automatically after loading OS? May be application should get some intents (make broadcast receiver)? I hope you can help me. Thank you for, anyway.

Upvotes: 2

Views: 122

Answers (2)

XXX
XXX

Reputation: 9072

Add to Manifest.xml:

...
<receiver android:name=".AutoStart">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED"></action>
    </intent-filter>
</receiver>
...

And create class:

package YourPackageName;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class AutoStart extends BroadcastReceiver
{   
    @Override
    public void onReceive(Context context, Intent intent)
    {   
        if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED"))
        {
            // Your Code
            Toast.makeText(context, "Started !!!", Toast.LENGTH_LONG).show();           
        }
    }
}

Upvotes: 3

user
user

Reputation: 87064

You'll have to make a BroadcastReceiver for the android.intent.action.BOOT_COMPLETED broadcast. When you receive this broadcast start your activity or service.

Upvotes: 4

Related Questions