0

I am working on an app which will be pre-installed in the android device and i want to trigger it in background when end user actually start using its smart phone from the very first time. So is there any broadcast fired for this purpose or any other possible way to do this?

karan
  • 93
  • 1
  • 11
  • 1
    yeah only when user register in your app that time you also get device IMEI number and stored it .then when user sign in that time you can check current device IMEI Number is same which is stored in database – Vishal Thakkar Feb 26 '16 at 13:11
  • Vishal, this app is installed by device manufacturer and it should trigger automatically once user starts using its new device, app is never launched by user manually. – karan Feb 26 '16 at 13:14
  • Have a look at [Time since first boot up](http://stackoverflow.com/questions/23282540/time-since-first-boot-up) – Onik Feb 26 '16 at 15:16

1 Answers1

0

I've used a BroadcastReceiver to accomplish the running something on start, and as for knowing if it's the first time, you could use a shared preference for the app to track it's status of first time or not with a boolean.

Define a BroadcastReceiver the receiver will need the following in the manifest:

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

    <receiver
        android:name="com.androidfactorem.airwaves.BootAirWaveService"
        android:enabled="true"
        android:permission="android.permission.RECEIVE_BOOT_COMPLETED" >
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </receiver>

You can see a full implementation of a BroadcastReceiver on boot in my git project https://github.com/pbirdsall/airwave

Peter Birdsall
  • 2,299
  • 4
  • 21
  • 45