I'm using the Flutter Image Cropper plugin. The first time I build the app and try to crop an image, the app crashes when I click to save the cropped image. But if I rebuild the app, it works perfectly. I think this may be related to permissions as I had a very similar problem with audio record permissions. This was solved by using the Permissions Plugin to request all permissions at the top of the app.
The permissions I am requesting in my AndroidManifest.xml file are;
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.INTERNET"/>
I've also added this to the AndroidManifest.xml;
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="#style/Theme.AppCompat.Light.NoActionBar"
/>
Here's the method I'm using to check permissions at the top of my widget tree;
Map<Permission, PermissionState> permission = await PermissionsPlugin
.checkPermissions([
Permission.CAMERA,
Permission.RECORD_AUDIO,
Permission.WRITE_EXTERNAL_STORAGE,
Permission.READ_EXTERNAL_STORAGE,
]);
Although the Permissions Plugin managed to solve the crashing of my app upon first build, it doesn't seem to have helped with the Flutter Image Cropper plugin.
Can anyone see what's going on?
Related
I'm developing a Flutter application. I've been using the open_file package for quite a while now to open files, but suddenly it doesn't work. I tried altering the code to print out the result of envokeMethod, and this is what shows up in the terminal.
I/flutter (13494): Result: {"type":-3,"message":"Permission denied: android.Manifest.permission.MANAGE_EXTERNAL_STORAGE"}
I tried adding the permission MANAGE_EXTERNAL_STORAGE in AndroidManifest.xml but it didn't work. I checked my app permission, it has access to file and media.
Any help would be greatly appreciated. Thanks.
After looking for some stuffs, I finally found the problem. When I checked my app's permission, for some reason there are only 2 options in File and Media section, which are Media only and Deny. For some reason file isn't included there, so I looked it up and found out that you need a specific permission starting from Android 11, which is called manageExternalStorage. So I had to ask for storage permission, then manageExternalStorage permission, and only then I could see a third option in the File and Media permission, which is All Files. After applying and asking for that permission, open_file works perfectly fine. BUT, it turns out that ManageExternalPermission is a pretty sensitive permission, which in my case, my application doesn't fulfill the requirement to ask for that permission, and was rejected due to that when I published it to Play Store. So I ended up forking the open_file package, changed it so that it doesn't require ManageExternalStorage permission, and it all works fine after that.
I am trying to display images in my flutter app. If I use a google link of the image, it is displayed. But, if I use my server URL, the image is not visible in the installed app.
I tried accessing the URL from both mobile and web browsers and it loads successfully there.
I have already used:
<manifest xmlns:android="...">
<uses-permission android:name="android.permission.INTERNET"/> <!-- Add this -->
</manifast>
I've put together a PWA and wanted to convert it into an Android App.
I've done so and my Android app consists of Main Activity and TWA that I start from the Main Activity.
Is there a way to switch from inside the TWA to some other activity on some event in the PWA running in this TWA? Like button click. Preferably from the HTML/Javascript of the PWA itself.
The end goal is to ad ads to the app (I'm using some paid APIs in the PWA so I need to at least break even and cannot monetize it on the web development side since Google AdSense and likes need context rich web-apps like blogs) and I've figured out that Google AdMob don't show up in TWA, they require a native Android Activity.
This question is closely related but I don't know where to put this URI:
Launching another activity from a Trusted Web Activity (TWA)
Thank you!
Yes, it is possible to start a different Activity. You will need to define a custom schema and link to that schema from the PWA:
This is defined inside AndroidManifest.xml, where the Activity you want to open from the PWA is specified. In the example below, we want to open ReviewActivity from the PWA, so we define:
<activity android:name=".ReviewActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="doom-fire" android:host="review" />
</intent-filter>
</activity>
Then, in the web application, whenever you link to doom-fire://review, ReviewActivity will be opened:
Rate app now!
I wrote a complete blogpost for the in-app review use-case that you may want to check out.
I have added AdMob's ads into my flutter application.it shows adds with a "test ad" tag on it.No impresions.No revenue yet.what should I do? and it only shows in my testing device but not showing other devices. Please guide me to resolve this issue.
enter image description here
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-4881405240833971~497555****"
/>
You have to create an adMob project corresponding to your app with ad units
If you already did this, then don't forget to create your own ad in adMob and replace in your code the test ad id by the one you created
There is a Flutter Codelab explaining the whole process of integrating ads, you might want to look at it
We were able to implement sharing to Instagram Stories, but not to Facebook Stories, following these instructions . Android is not able to find an app for the intent com.facebook.stories.ADD_TO_STORY, despite Facebook app being installed and updated. Has anybody been able to accomplish that?
It might be too late but i thought to answer it if it can help people who might be facing issues in sharing to instagram without Intent Chooser dialog.
Facebook expects us to launch an intent chooser dialog to select from 4 -5 activities within facebook app itself that can handle com.facebook.stories.ADD_TO_STORY as action.
Nevertheless here is the code i used to launch the exact story editor screen from facebook app. It uses ACTION_SEND instead of com.facebook.stories.ADD_TO_STORY.
So First define a fileprovider inside application tag in manifest
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/file_provider_paths" />
</provider>
Then keep file_provider_paths.xml inside xml folder in res directory.
file_provider_paths.xml
<paths>
<external-path
name="share"
path="/" />
</paths>
Then perpare a uri of file you want to share
File file = new File(imagePath);
Uri fileUri = FileProvider.getUriForFile(getApplicationContext(),getPackageName()+".fileprovider",file);
Then send intent to facebook as below
Intent storiesIntent = new Intent(Intent.ACTION_SEND);
storiesIntent.setComponent(new ComponentName("com.facebook.katana", "com.facebook.composer.shareintent.AddToStoryAlias"));
storiesIntent.setDataAndType(uri, "image/*");//for background image
storiesIntent.putExtra("interactive_asset_uri", uri);//for sticker assets
storiesIntent.putExtra("content_url", "https://dexati.com/");
grantUriPermission("com.facebook.katana", uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivityForResult(storiesIntent, 0);
Here we are making explicit call to the story editor activity of facebook app.