mcr619619
mcr619619

Reputation: 435

Can the android Emulator in eclipse can be shutdown? how? need it for testing my Alarm Manager auto start at boot

I dont have an actual Android phone, and i want to test Alarm, but i dont know if its the code that has error, or the emulator doesnt do the way like an actual phone in terms of booting.

the Autostart Code is from here: Alarm Manager Example

The code doesnt give me error, the simple alarm manager and service is OK, but the autostart of the alarm is not working, i hope its only on the emu, wish it will work in an actual phone. The code below is from the above-mentioned thread, and it also the one that i uses.. i'd put it because maybe the code are the problems

Manifest

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

And this is the on-boot trigger

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

public class AutoStart extends BroadcastReceiver
{   
    Alarm alarm = new Alarm();
    @Override
    public void onReceive(Context context, Intent intent)
    {   
        if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED"))
        {
            alarm.SetAlarm(context);
        }
    }
}

Upvotes: 2

Views: 1643

Answers (3)

mcr619619
mcr619619

Reputation: 435

adb -e shell am broadcast -a android.intent.action.BOOT_COMPLETED

type this, after going to android sdk/platform-tools through command line

this will send an artificial BOOT_COMPLETED action

Upvotes: 1

Gaurav Navgire
Gaurav Navgire

Reputation: 780

Go to the "platform-tools" folder in your "android-sdk" folder through command line. Type following commands:

adb devices

-- Here it will list the current emulator you have started earlier. If the emulator is dislayed, which will, then type below command.

adb reboot

-- This will reboot the emulator without touching any button on on the emulator.

Upvotes: 1

Juned
Juned

Reputation: 6326

You can long press powerOff button which is provided in Emulator then it will show you different options like Silent Mode,Airplane Mode, Power Off. In other case you can restart your emulator. This way you can check your BOOT_COMPLETED broadcast.

Upvotes: 0

Related Questions