Error In Wifi Toggle Android Code - android

I get this error when I press the button for the wifi toggle and the app stops working.It mentions that the user has no permission to access wifi state.The thing is its already declared in the Manifest file.
Permissions used:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Error
FATAL EXCEPTION: main
Process: com.example.something.callblocker, PID: 935
java.lang.SecurityException: WifiService: Neither user 10052 nor current process has android.permission.ACCESS_WIFI_STATE.
at android.os.Parcel.readException(Parcel.java:1472)
at android.os.Parcel.readException(Parcel.java:1426)
at android.net.wifi.IWifiManager$Stub$Proxy.getWifiEnabledState(IWifiManager.java:808)
at android.net.wifi.WifiManager.getWifiState(WifiManager.java:1029)
at android.net.wifi.WifiManager.isWifiEnabled(WifiManager.java:1041)
at com.example.stamatis.callblocker.powersavings$2.onClick(powersavings.java:55)
at android.view.View.performClick(View.java:4438)
at android.widget.CompoundButton.performClick(CompoundButton.java:100)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)

If this is happening and you are saying that android.permission.ACCESS_WIFI_STATE this is already present in manifest, then there is only one possibility that user has explicitly stopped this permission.
Check if this crash is in Marshmallow i.e API 23. Google has provided the user power to remove the permission of app explicitly.
You can read : http://www.greenbot.com/article/2990078/android/how-to-toggle-app-permissions-in-android-marshmallow.html
Only solution is to check for permission at runtime before doing toggle.
This is how you can do this :
private boolean checkWriteExternalPermission()
{
String permission = "android.permission.ACCESS_WIFI_STATE";
int res = getContext().checkCallingOrSelfPermission(permission);
return (res == PackageManager.PERMISSION_GRANTED);
}

Needs to be looked at by authorities for fraud and illegal activity steal the token page

Related

Difference between "Bookmark History" permission tag

What is the difference between the two Android permission below related to browser Bookmark History?
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/> -->
<uses-permission android:name="android.permission.READ_HISTORY_BOOKMARKS" />
My app works fine with the first one only, and crash with the second.
SDK version:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
Error Log when I use the second permission tag:
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.SecurityException: Permission Denial: reading com.android.browser.provider.BrowserProvider2 uri content://browser/bookmarks from pid=5063, uid=10050 requires com.android.browser.permission.READ_HISTORY_BOOKMARKS, or grantUriPermission()
at android.os.Parcel.readException(Parcel.java:1431)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:385)
at android.content.ContentResolver.query(ContentResolver.java:414)
at android.content.ContentResolver.query(ContentResolver.java:357)
at course.labs.permissionslab.BookmarksActivity.loadBookmarks(BookmarksActivity.java:56)
at course.labs.permissionslab.BookmarksActivity.access$000(BookmarksActivity.java:14)
at course.labs.permissionslab.BookmarksActivity$1.onClick(BookmarksActivity.java:32)
at android.view.View.performClick(View.java:4240)
at android.view.View$PerformClick.run(View.java:17721)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Android version: 4.3.1
Thanks!
This release removes support for global bookmarks. The android.provider.Browser.getAllBookmarks() and android.provider.Browser.saveBookmark() methods are now removed. Likewise, the READ_HISTORY_BOOKMARKS and WRITE_HISTORY_BOOKMARKS permissions are removed. If your app targets Android 6.0 (API level 23) or higher, don't access bookmarks from the global provider or use the bookmark permissions. Instead, your app should store bookmarks data internally.
https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-bookmark-browser

Mock Location permission issue on release app

I developed Fake GPS application and all my codes work nicely on debug mode.
When i try "mock location" on **release version**, i got this error;
java.lang.SecurityException: Requires `ACCESS_MOCK_LOCATION` permission
I already had ACCESS_MOCK_LOCATION in debug/AndroidManifest file.
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
And already "Allow Mock Location" checked in "Delevoper Options".
Finally; i cant add "ACCESS_MOCK_LOCATION" on main/AndroidManifest.xml. Android Studio dont approve this permission.
I tried on Samsung Note 3, V: 4.4.2
Whole of the expection;
java.lang.SecurityException: Requires ACCESS_MOCK_LOCATION permission
at android.os.Parcel.readException(Parcel.java:1472)
at android.os.Parcel.readException(Parcel.java:1426)
at android.location.ILocationManager$Stub$Proxy.addTestProvider(ILocationManager.java:944)
at android.location.LocationManager.addTestProvider(LocationManager.java:1205)
at egebit.getlocation.MapsActivity.mockLocation(MapsActivity.java:201)
at egebit.getlocation.MapsActivity$2.onClick(MapsActivity.java:118)
at android.view.View.performClick(View.java:4652)
at android.view.View$PerformClick.run(View.java:19311)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5692)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
In that case you are just adding for debug, but it's needed on release too.
You could add to Manifest(not debug) file with ignore value
<uses-permission
android:name="android.permission.ACCESS_MOCK_LOCATION"
tools:ignore="MockLocation" />

How to handle java.lang.SecurityException: Requires READ_PHONE_STATE for android.text.format.DateFormat.getDateFormat?

My app was sent a stack trace for device Y625-U21 (HWY625-U), the app doesn't ask for READ_PHONE_STATE because the docs say nothing about using this permission for getting dateFormat. We have tested the app in various devices and this doesn't happen.
java.lang.SecurityException: Requires READ_PHONE_STATE: Neither user 10149 nor current process has android.permission.READ_PHONE_STATE.
at android.os.Parcel.readException(Parcel.java:1472)
at android.os.Parcel.readException(Parcel.java:1426)
at com.android.internal.telephony.IPhoneSubInfo$Stub$Proxy.getSubscriberId(IPhoneSubInfo.java:317)
at android.telephony.TelephonyManager.getSubscriberId(TelephonyManager.java:1094)
at android.text.format.DateFormat.getDateFormatStringForSetting(DateFormat.java:262)
at android.text.format.DateFormat.getDateFormatForSetting(DateFormat.java:250)
at android.text.format.DateFormat.getDateFormat(DateFormat.java:236)
at edu.usf.cutr.opentripplanner.android.util.ConversionUtils.getTimeWithContext(ConversionUtils.java:217)
at edu.usf.cutr.opentripplanner.android.util.ConversionUtils.getTimeWithContext(ConversionUtils.java:210)
at edu.usf.cutr.opentripplanner.android.fragments.MainFragment.fillItinerariesSpinner(MainFragment.java:3521)
at edu.usf.cutr.opentripplanner.android.fragments.MainFragment.onTripRequestComplete(MainFragment.java:3462)
at edu.usf.cutr.opentripplanner.android.tasks.TripRequest.onPostExecute(TripRequest.java:171)
at edu.usf.cutr.opentripplanner.android.tasks.TripRequest.onPostExecute(TripRequest.java:60)
at android.os.AsyncTask.finish(AsyncTask.java:632)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5135)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
at dalvik.system.NativeStart.main(Native Method)
I can say that when your app gets a lot of installs in Google Play you will receive a lot of strange crash reports in Google Developer console.
Sometimes there is nothing you can do with it and you have to put your code in try/catch block.
I don't know all the details about your case, but in mine it was the only solution.
try {
//your code here
} catch (SecurityException e) {
e.printStackTrace();
//do smth in this scenario
}
include this permission in manifest file
READ_PHONE_STATE
You are getting this exception becoz you haven't declare this permission in manifest file.

How to fix ussd code error?

My Logcat:
08-23 01:32:12.806 1299-1299/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.haftasia.easycode, PID: 1299
java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:xxxxxxxx cmp=com.android.phone/.OutgoingCallBroadcaster } from ProcessRecord{43f9a738 1299:com.haftasia.easycode/u0a181} (pid=1299, uid=10181) requires android.permission.CALL_PHONE
at android.os.Parcel.readException(Parcel.java:1472)
at android.os.Parcel.readException(Parcel.java:1426)
at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2109)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1419)
at android.app.Activity.startActivityForResult(Activity.java:3442)
at android.app.Activity.startActivityForResult(Activity.java:3403)
at android.app.Activity.startActivity(Activity.java:3645)
at android.app.Activity.startActivity(Activity.java:3613)
at com.haftasia.easycode.Day_3G_Mci$1$1.onClick(Day_3G_Mci.java:52)
at android.view.View.performClick(View.java:4448)
at android.view.View$PerformClick.run(View.java:18461)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5065)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
You must add this permission in your AppManifest.xml:
<uses-permission android:name="android.permission.CALL_PHONE" />
Your error occurred because you didn't add it.
Since the logcat is saying everything what you looking for why dont you try to add permission ?
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
You seem to have an intent which makes an call but however for any app to make a call it requires the permission.
To add it in the Manifest before the application tag add the following
<uses-permission android:name = "android.permission.CALL_PHONE"/>

IBM MobileFirst - Native Android Application adding push manifest permissions

I am confused about the permissions section for IBM's MobileFirst GMS Push notifications found here. (Section 5)
https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-0/notifications/push-notification-native-android-applications/
I have added all of these permissions verbatim, but im getting an error saying i havn't added manifest permissions. Do i need to modify the package names in these permissions?
Is this activity built in?
<activity
android:name="com.worklight.androidnativepush.AndroidNativePush"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:launchMode="singleTask">
Here is the error logcat
07-25 23:24:48.285 17146-17146/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.companyname.hitch.mobilefirsttestapp, PID: 17146
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.companyname.hitch.mobilefirsttestapp/com.companyname.hitch.mobilefirsttestapp.push.PushActivity}: java.lang.RuntimeException: Your manifest is not allowed to work with push. Android Manifest Error: Missing permission in manifest: com.companyname.hitch.mobilefirsttestapp.permission.C2D_MESSAGE
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Your manifest is not allowed to work with push. Android Manifest Error: Missing permission in manifest: com.companyname.hitch.mobilefirsttestapp.permission.C2D_MESSAGE
at com.worklight.wlclient.api.WLPush.<init>(WLPush.java:180)
at com.worklight.wlclient.api.WLClient.getPush(WLClient.java:957)
at com.companyname.hitch.mobilefirsttestapp.push.PushActivity.onCreate(PushActivity.java:19)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
When creating a MobileFirst-based Hybrid app with the Android environment, MobileFirst will be creating it based on a template with a set of predefined permissions and activities.
In a native application, you are the one creating it. MobileFirst only supplies you with the SDK and a set of integration instructions.
The activity that you mentioned in the question (taken from the tutorial page) is the activity of the sample application included in the tutorial. In your own app's AndroidManifest.xml you will see your app's name instead of "androidnativepush" (or rather need to create it).
Make sure not to use "androidnativepush" anywhere unless that is your app name.

Categories

Resources