android-6.0-marshmallow

Getting mobile data usage history using NetworkStatsManager

ぐ巨炮叔叔 提交于 2019-12-17 17:42:03
问题 I want to know the data usage history and noticed the "new" android-6 NetworkStatsManager which seems positive (I've used TrafficStats a while but that won't cover anything previous a reboot). From the API documentation: NOTE: This API requires the permission PACKAGE_USAGE_STATS, which is a system-level permission and will not be granted to third-party apps. However, declaring the permission implies intention to use the API and the user of the device can grant permission through the Settings

Provide custom text for Android M permission dialog

感情迁移 提交于 2019-12-17 16:15:43
问题 Is it possible to provide a custom text for the system dialog which is displayed when the user is asked to grant permission? 回答1: No, you can't customize the text of the dialog, but you can provide an explanation before request the permission. Quoting from developer.android.com: Request Permissions If your app needs a dangerous permission that was listed in the app manifest, it must ask the user to grant the permission. Android provides several methods you can use to request a permission.

Provide custom text for Android M permission dialog

南楼画角 提交于 2019-12-17 16:13:13
问题 Is it possible to provide a custom text for the system dialog which is displayed when the user is asked to grant permission? 回答1: No, you can't customize the text of the dialog, but you can provide an explanation before request the permission. Quoting from developer.android.com: Request Permissions If your app needs a dangerous permission that was listed in the app manifest, it must ask the user to grant the permission. Android provides several methods you can use to request a permission.

How can I customize permission dialog in Android?

荒凉一梦 提交于 2019-12-17 16:01:47
问题 Suppose I request a permission at runtime like the following: ActivityCompat.requestPermissions(thisActivity, new String[]{Manifest.permission.READ_CONTACTS}, MY_PERMISSIONS_REQUEST_READ_CONTACTS); Android system creates a popup dialog to request permission. How can I define a custom layout for that dialog? 回答1: The short answer is, you can't . As android documentation puts: When your app calls requestPermissions(), the system shows a standard dialog box to the user. Your app cannot configure

How to manage Runtime permissions android marshmallow espresso tests

…衆ロ難τιáo~ 提交于 2019-12-17 15:38:52
问题 I'm using espresso for testing but sometimes I try to get an image form external storage and with marshmallow I need a Runtime permission otherwise there will be an Exception crash and the test will fail. androidTestCompile 'com.android.support.test:runner:0.4' androidTestCompile 'com.android.support.test:rules:0.4' androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1' androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.1' androidTestCompile('com

Grant permission required for EXTERNAL_STORAGE in Android M?

纵然是瞬间 提交于 2019-12-17 11:52:34
问题 Will the Android permissions WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE trigger the new grant permission dialog of Android M? 回答1: I agree with Guillaume Perrot 's answer. I have met the similar question when I write the permission of READ_WRITE_EXTERNAL_STORAGE in AndroidManifest.xml with no permissions showing up in the app by default , people need to switch the toggle button of storage in the app permissions.Then I modify my targetSdkVersion in build.gradle to less than 23(MNC) and

An Android app remembers its data after uninstall and reinstall

∥☆過路亽.° 提交于 2019-12-17 10:07:39
问题 While developing an Android app targeting all versions above 4.1, I observed that uninstalling my app and installing it again does not clear its data. The app is designed to store the details that it asks in its first screen. After uninstalling and installing again in OS version 4.4.4, the app prompts the user to fill in the data, which is normal. However in version 6.0 the same install/uninstall sequence bring backs the data originally input. I tried to ensure by visiting /data/data/my

Android: what to choose for requestcode values?

陌路散爱 提交于 2019-12-17 07:20:13
问题 Methods like ActivityCompat.requestPermissions require that I pass them a requestcode that I can later test in a callback (in this case onRequestPermissionsResult ). Is there some best practice sort of value I'm supposed to pass in the requestcode? I've noticed that if I just enter a random int I sometimes get an error like this: java.lang.IllegalArgumentException: Can only use lower 8 bits for requestCode 10-25 16:47:43.652 8315-8315/? E/AndroidRuntime: FATAL EXCEPTION: main 10-25 16:47:43

setExactAndAllowWhileIdle - is not exact as of developer reference

ⅰ亾dé卋堺 提交于 2019-12-17 07:11:08
问题 AlarmManager on API19 has the method setExact() to set an exact alarm. Exact means --> If I set an alarm to 2:01 pm it will be triggered at 2:01 pm On API 23 - Marhsmwallow (6.0) there is a new method setExactAndAllowWhileIdle() , but as of the reference it is not EXACT because it will trigger only every minute and in low power idle mode only every 15 minutes . Exact != every 15 minutes :-) So how can I achieve an exact alarm with AlarmManager in 6.0 ? If a user adds a reminder or a calendar

ConnectivityManager getNetworkInfo(int) deprecated

≯℡__Kan透↙ 提交于 2019-12-17 03:46:14
问题 Using compileSdkVersion 23 , however trying to support as far back as 9. getNetworkInfo(int) was deprecated in 23. The suggestion was to use getAllNetworks() and getNetworkInfo(Network) instead. However both of these require minimum of API 21. Is there a class that we can use in the support package that can assist with this? I know that a solution was proposed before, however the challenge of my minimum API requirements of 9 poses a problem. 回答1: You can use: getActiveNetworkInfo();