2

I use the following code, to ask user for enabling scan always available

if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.JELLY_BEAN_MR2 && !wifiManager.isScanAlwaysAvailable)
        startActivity(Intent(ACTION_REQUEST_SCAN_ALWAYS_AVAILABLE))

And it's works as it should, but on Samsung Galaxy Note 4 text in window appears as "null requests permission"


Screenshot:

Screenshot

How to replace null with app name?

Vivek Mishra
  • 5,669
  • 9
  • 46
  • 84
Dmytro Rostopira
  • 10,588
  • 4
  • 64
  • 86

1 Answers1

-2

Why dont you try this instead of comparing version name try comparing the version number

private static final int REQUEST_SCAN_ALWAYS_AVAILABLE = any_number;

WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);

if (Build.VERSION.SDK_INT >= 18 && !wifiManager.isScanAlwaysAvailable()) {
  startActivityForResult(new Intent(WifiManager.ACTION_REQUEST_SCAN_ALWAYS_AVAILABLE, REQUEST_SCAN_ALWAYS_AVAILABLE));
}

and for the resutl use below event

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Check which request we're responding to
    if (requestCode == REQUEST_SCAN_ALWAYS_AVAILABLE) 
     {
        // Make sure the request was successful
        if (resultCode != RESULT_OK) 
         {
             //User has not enabled the scan always available inform him to activate it
         }
     }
}
Zain Ul Abidin
  • 2,467
  • 1
  • 17
  • 29