I'm getting below Error on code
The call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with checkPermission) or explicitly handle a potential SecurityException less... (Ctrl+F1)
Inspection info: This check scans through your code and libraries and looks at the APIs being used, and checks this against the set of permissions required to access those APIs. If the code using those APIs is called at runtime, then the program will crash.
Furthermore, for permissions that are revocable (with targetSdkVersion 23), client code must also be prepared to handle the calls throwing an exception if the user rejects the request for permission at runtime. Issue id: MissingPermission
Code:
@SuppressWarnings( "deprecation" )
void setDeviceImei() {
TelephonyManager telephonyManager = ( TelephonyManager ) getSystemService( Context.TELEPHONY_SERVICE );
Utils.setIMEI( context, String.valueOf( telephonyManager.getDeviceId() ) );
WifiManager wm = ( WifiManager ) getApplicationContext().getSystemService( WIFI_SERVICE );
String ip = Formatter.formatIpAddress( wm.getConnectionInfo().getIpAddress() );
Utils.setIpAddress( context, ip );
int v = 0;
try {
v = context.getPackageManager().getPackageInfo( context.getPackageName(), 0 ).versionCode;
Utils.setVersionCode( context, v );
}
catch( NameNotFoundException e ) {
e.printStackTrace();
}
if( !Utils.isConnectingToInternet( context ) ) {
alertpopup( context, context.getResources().getString( R.string.no_internet ) );
return;
} else {
timer = new Timer();
timer.schedule( new TimerTask() {
public void run() {
callValidateImeiApi();
timer.cancel();
timer = null;
}
}, 500 );
}
}
Error on below line:
Utils.setIMEI( context, String.valueOf( telephonyManager.getDeviceId() ) );
Please assist to clear it!