swetha swetha - 6 months ago 8
Android Question

Hi,In 6.0 Permission to make call is asking everytime

In 6.0 marshmallow, I want to add permission to making call. below code is working in all devices except Moto G, In Moto G permission is asking everytime when I start making call.

if(android.os.Build.VERSION.SDK_INT >= 23){
if(checkPermission(c, Manifest.permission.READ_PHONE_STATE)){
// success
}else{
// faliure
}
}

Answer

Create intent service like below and add your code in that

public class RSSPullService extends IntentService {
    @Override
    protected void onHandleIntent(Intent workIntent) {
        // Gets data from the incoming Intent
        String dataString = workIntent.getDataString();
        ...
        // Do work here, based on the contents of dataString
        ...
    }
}