android-permissions

What's the best way to check for permissions at runtime using MVP architecture?

南楼画角 提交于 2019-12-02 20:38:52
I'm developing an android app in which I have to ask for permissions at runtime. I'm wondering about the best way to implement that using Model-View-Presenter architecture. My initial thought was to have the presenter call a component responsible for permissions(say a PermissionHandler ), and update view accordingly. The issue is that the code to check for permissions is tightly coupled with the Activity class. Here are some of the methods involved that require an Activity or Context: ContextCompat.checkSelfPermission() ActivityCompat.shouldShowRequestPermissionRationale() ActivityCompat

Android Marshmallow, “dangerous” protection level and system components/apps

我怕爱的太早我们不能终老 提交于 2019-12-02 19:40:06
I'm developing an application that going to be pr-installed (as a system app) on the firmware. from the documentation so far about the relation between system apps , new permissions model, and the protection levels - I don't understand exactly when system app needs (if at all) to request user permission. My problems starts when I try to use the WRITE_EXTERNAL_STORAGE permission. from the documentation I can see that it marked as "dangerous" permission. - does "dangerous" permissions grant automatically to system apps? when I use WRITE_EXTERNAL_STORAGE permission (as a system app) I'm getting

How do I create a shortcut for any app on desktop?

独自空忆成欢 提交于 2019-12-02 19:34:38
I think I've tried all the solutions I found on the internet, but no one worked - no force close, but nothing appears on desktop. Now, I have this: private void createShortcutOnDesktop(Application app) { Intent shortcutIntent = new Intent(); shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, app.getIntentShortcut()); shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, app.getName()); shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context, R.drawable.home_button)); shortcutIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");

Options for dealing with Android 6.0's new permissions requirements from a service or model component?

筅森魡賤 提交于 2019-12-02 19:04:51
问题 I'm looking into porting some existing code to take Android M's new way of dealing with permissions into consideration. However the permission API needs to have an activity associated with it (for example the requestPermissions() method's first parameter is an activity). So how should a service that needs to check if a permissions has been granted and request for permissions use this new API if the service doesn't have an activity? Is it possible for the service to create a dummy invisible

Can you request permissions synchronously in Android Marshmallow (API 23)'s runtime permissions model?

天涯浪子 提交于 2019-12-02 18:45:48
Say you have a method like this: public boolean saveFile (Url url, String content) { // save the file, this can be done a lot of different ways, but // basically the point is... return save_was_successful; } Throughout your app, if you want to save a file to external storage, you do something like... if (saveFile(external_storage_url, "this is a test")) { // yay, success! } else { // notify the user something was wrong or handle the error } This is a simplified example, so don't get on my case about blocking the UI, handling exceptions properly, etc. If you don't like file saving, you could

No such file or Directory only in Android 6.0

浪尽此生 提交于 2019-12-02 17:00:52
问题 Below code is working fine on pre-Marshmallow devices but not in Marshmallow. These are the permissions in Manifest <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> Here is the code public void saveImageToSDCard(Bitmap bitmap) { File myDir = new File( Environment .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),

Allow fine location permission to replace fragment

余生颓废 提交于 2019-12-02 13:17:13
I want to ask user does he want to grant a permission to accces his fine location and only if he grant it I want to replace a fragment and open the locator fragment. In locator fragments there are some stores that user can see based on his location. If he doesn't allow access to fine location I want to show him proper message. This is the code: else if (id == R.id.nav_locator) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1); fragment = new LocatorFragment(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace

No such file or Directory only in Android 6.0

痴心易碎 提交于 2019-12-02 10:33:49
Below code is working fine on pre-Marshmallow devices but not in Marshmallow. These are the permissions in Manifest <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> Here is the code public void saveImageToSDCard(Bitmap bitmap) { File myDir = new File( Environment .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), pref.getGalleryName()); myDir.mkdirs(); Random generator = new Random(); int n = 10000; n = generator

java.io.FileNotFoundException: (Permission denied) when writing an object using ObjectOutputStream

人走茶凉 提交于 2019-12-02 09:34:35
问题 I have been trying to work around this for several hours and I am extremely frustrated so I am coming to you guys for some guidance. I am trying to save and retrieve a User object I have created. I want to make it so that I can save and retrieve this User object from any intent throughout my application, so I decided to go with a FileInput and Output stream. I have included my code for both below. Here is my output data method: public static void serializeDataOut(User ish) { try { String path

Xamarin Support Package error

笑着哭i 提交于 2019-12-02 09:06:25
Please install package: 'Xamarin.Android.Support.Design' available in SDK installer. Android resource directory C:\Users\Srinivasarao\AppData\Local\Xamarin\Android.Support.Design\23.0.1.3\embedded\./ doesn't exist. Sample.Droid Please install package: 'Xamarin.Android.Support.Design' available in SDK installer. Java library file C:\Users\Srinivasarao\AppData\Local\Xamarin\Android.Support.Design\23.0.1.3\embedded\classes.jar doesn't exist. Sample.Droid Please install package: 'Xamarin.Android.Support.v7.AppCompat' available in SDK installer. Android resource directory C:\Users\Srinivasarao