2

I have an app that have push notification feature. I notice that some of the device especially chinese phone like xiamoi,oppo,one plus etc having option for auto start and this control the push notification. Am not getting Push Notification when the app is not in background or in recent list.By default my app auto start is OFF

But am confused why the app like Flipkart,Amazon, Whatsapp, Hike the auto start is ON by default.

Is there is any option to set the auto start as ON by default

Binil Surendran
  • 2,524
  • 6
  • 35
  • 58
  • Unfortunately no . There is no such options. Although what you can do is For some of the devices There is a hack to open its Security center . Refer to this So [Thread](https://stackoverflow.com/questions/34149198/how-to-enable-auto-start-for-my-app-in-xiaomi-programmatically) – ADM Oct 11 '17 at 14:01
  • @ADM in the tread shows how to show the auto start page by using intent and each manufacture its different. Also there is no option weather the auto start is ON/OFF before we bypass to the auto start page. So i think its not a right solution. You can check that in whatsapp and Flipkart at the time of fresh installation without going to auto start page by default the auto start is ON. Am trying to find the solution like this – Binil Surendran Oct 12 '17 at 03:32
  • Yeah thats what i figured out after so much searching. There is no such Api to check auto start status whether its ON/Off . Talking about whatsApp of flipkart or such other apps I read some where that these are white listed apps by the Manufactures . You can check it in Skype lite app . Download it in xiaomi Device it will do same thing . It will send you to the Setting screen and you can just bypass it . the app won't do anything. – ADM Oct 12 '17 at 04:54
  • @Frank van Puffelen sir , can you please check this question – Binil Surendran Oct 12 '17 at 08:57

1 Answers1

0

I think, better way is using default Android API features to run service after boot, not use custom features like used in chinese phones. To make autrun by default Android way, you should add to mainfest:

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

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

And write Boot receiver:

public class BootReceiver extends BroadcastReceiver {

    public BootReceiver() {
        // TODO Auto-generated constructor stub
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        //Run your service here 
    }
}
Serge
  • 9
  • 1