My apps if already install, can't start service. If running service must setup in Security Menu and then allow this apps with manual setting. And i want for setup not manual setup but with programmatically in my code service.
My Code,
Service
public class MyService extends Service {
@Override public void onCreate() { super.onCreate(); } @Override public int onStartCommand(Intent intent, int flags, int startId) { Toast.makeText(this, "Service Started...", Toast.LENGTH_LONG).show(); return Service.START_STICKY; } @Override public void onDestroy() { Toast.makeText(this, "Service Destroyed...", Toast.LENGTH_LONG).show(); } @Nullable @Override public IBinder onBind(Intent intent) { return null; }
}
Android Manifest
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <service android:name=".MyService" android:exported="false" android:enabled="true"> </service> </application>
Please Help me anyone.. :'(