How to exit from Flutter after calling flutter activity from android? - java

I am calling a flutter module/aar from my Android app. I used an intent which will be created after a button press which starts a flutter module/aar.
Its working fine but I can't find any documentation guiding how to exit from flutter and start some other android intent or navigate back to previous android screen buy doing say a button press (without pressing back button).

You can use the SystemNavigator.pop() method:
Removes the topmost Flutter instance, presenting what was before it.
On Android, removes this activity from the stack and returns to the previous activity.

Related

Android - How to detect when user click recent app?

I want to develop a custom launcher android for Samsung Tablet where user can only exit the launcher with a passcode input.
Currently I face problem in recent app button. If user click recent app button, and then click the recent app, then click backpressed, device will go to TouchWiz launcher even I already set my launcher as a default launcher. Also, I disable the notification bar so user can't access it. However, when it go to TouchWiz via backpressed at recent app, the notification also disable, it should be able when in TouchWiz launcher.
My proposed solution is to detect when user click recent app and forbid any action that can cause the changes of current view.
You can check onWindowFocusChanged method. You Activity will get a callback on this method when you click recent apps or press back button from it. When you click on recent apps hasFocus will be false and when you press back it will be true.
documentation
I can't detect the recent app clicked. So I use onPause() to detect if my app is on foreground or background. If is in onPause() then my app is on background, if so, I do startActivity(myLauncher) so other app won't launched.

How to not let the user exit my app?

Hi i need something to don't let users exit my app without pressing the button exit. Basicly if they use home or any other button the app can't exit. How can i make this? Im using android studio and im new to this language.
The only thing you can do is override the onBackPressed method but unfortunately, you can't stop the home button from closing the app unless the phone is rooted or something. But when you do close the app with the home button it is still in Android's memory which prevents cold starts the next time the user opens the app. I am not sure why the information would be helpful though.

Android - 'Complete action using' keeps showing even after selecting 'Always'

I'm trying to use an intent to browse for images. I managed to get my code working but the only problem is that every time I choose the browse file button, the app always shows the pop up dialog 'Complete action using' even after Always is selected.
I still want the user to select from the available app installed and set it as default when 'always' is selected.
Do I need to programmatically save the user's choice? I have only tested this in Genymotion's emulator (Android's Studios emulator is very slow in my laptop) and my Lenovo S820 Android 4.4.2. Is it a specific bug in my phone or am I missing something? Thank you in advance.
I have searched everywhere and found this similar
question, but it's also unanswered.
I am calling my intent like this:
public Intent browse(){
Intent getterIntent = new Intent(Intent.ACTION_GET_CONTENT);
getterIntent.addCategory(Intent.CATEGORY_OPENABLE);
getterIntent.setType("image/*");
return getterIntent;
}

Fresh loading activity every time of calling it

In an android App im showing advertisement from a local advertisement company.
My problem is when start App and close it with back button, and back to it by clicking on its icon, i see the same Ad. But when i close the app from android task manager and back to the app, i see another Ad.
I know this can have multiple reasons and my question is not clear, But my main questions that how i can set each activity runs like first time of running the app? What should cause this reaction? its like a cookie system... i want every activity show new Ad!
Here you can see example code:
http://github.com/adad-project/client-app-sample
Move
Adad.initialize(getApplicationContext());
((AdView) findViewById(R.id.banner_ad_view)).setAdListener(mAdListener);
to onStart and remove from onCreate in MainActivity
Do similar thing in other activities.

How do I listen to Android's contacts launch activity?

I want to know when Android's contact launch activity is opened because my application opens after a call is finished and then the contact launch activity is opened after it meaning it will cover my app's activity leading to that I have to press "back" button to see my app.
That is, I want to open my app after contact launch activity has been opened.
All help is greatly appreciated!
This is not supported by the Android SDK. Sorry!

Categories