I have Flutter plugin
That shows fullscreen notification from background or when terminated using Push notification
This screen is built in Kotlin
and it has a button that when pressed
it launch the Main Intent of the application - the code in that plugin is the following
ACTION_CALL_ACCEPT -> {
saveCallState(callIdToProcess!!, CALL_STATE_ACCEPTED)
channel.invokeMethod("onCallAccepted", parameters)
var launchIntent = getLaunchIntent(context!!)
launchIntent?.action = ACTION_CALL_ACCEPT
context.startActivity(launchIntent)
}
this works fine and it launch the application to the default route
I want it to open specific screen instead , also if there is a way to pass the parameters to this screen
I don't know if this can be achieved with channel.invokeMethod
because this is in the plugin side , I cannot run Navigator inside it's Dart code (NO context available there)
I only know basics of Kotlin that's why I don't know how to achieve this properly
Thanks in advance .
Related
AIM : To load specific element from unity 3D into flutter Android App.
Issue:
I am using flutter_unity_widget in flutter to show unity 3D content. I work fine until i use method like _unityWidgetController.postJsonMessage, It show black screen and content is not accessable.
current code in flutter
// Callback that connects the created controller to the unity controller
void onUnityCreated(controller) {
_unityWidgetController = controller;
unity(_unityWidgetController);
}
unity(UnityWidgetController _unityWidgetController){
_unityWidgetController.postJsonMessage("Model Selector" , "SelectModel", {"value" : 3});
_unityWidgetController.postMessage("Model Selector" , "SelectModel", "3");
}
flutter_unity_widget: ^2020.3.25
Black screen problem is related with Unity crash. I am working on a Flutter AR App. I am using Flutter + Unity + Vuforia and flutter_unity_widget: ^2022.1.0+2 version. Please try to find your Unity crash. I can share with you my working code example for sending messages from my Flutter App to Unity. I am using it for; when Unity is ready, send this message from Flutter to Unity:
void _onUnityCreated(controller) {
controller.resume();
_unityWidgetController = controller;
_unityWidgetController.postMessage("myUnityObject", "myUnityMethod", "myStringParam");
}
I'm triyng to show the status bar in an Android phone using Unity. I have try this code:
void Start() {
this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
But an error appear;
Assets/Scenes/Control/control.cs(15,34): error CS0103: The name 'WindowManager' does not exist in the current context
Does I need to call or import another package? Some could help me with this detail. Thanks in advance.
You cannot use Android Java functions directly in Unity. You can only use whats available in Unity C Sharp. Unity doesn’t understand the method. Suggested workaround, use a ‘Slider’ UI element and manipulate it in a custom c sharp script. Complicated workaround create a custom Unity Plugin which calls the native Android method (possible but complex).
Working on a Project and stuck in an Issue:
Hardware Back Button Reloading Application (I am using Angular Router in this application).
My Code to Exit Application:
ionViewDidEnter(){
this.subscription = this.platform.backButton.subscribe(()=>{
navigator['app'].exitApp();
});
}
ionViewWillLeave(){
this.subscription.unsubscribe();
}
While same logic Working in other applications. but in this application its reloading the application not exiting it.
P.S: i have also tried it to put in platform.ready() but no luck.
With IONIC 4, there is new method subscribeWithPriority developed to handle race between soft & hard back button. Try modifying your code like below:
this.platform.backButton.subscribeWithPriority(1, () => {
navigator['app'].exitApp();
});
subscribeWithPriority() stops the propagation of the event after its execution and if we subscribe with high priority and execute our prefered navigation instead of default one then it is going to work as you want.
More reference docs for details:
https://github.com/ionic-team/ionic/commit/6a5aec8b5d76280ced5e8bb8fd9ea6fe75fe6795
https://medium.com/#aleksandarmitrev/ionic-hardware-back-button-nightmare-9f4af35cbfb0
UPDATES:
Try using this new version of exitApp cordova plugin. I haven't
tried myself but looks promising from popularity.
Also try to empty the page stack from Navcontroller or go to your home screen, seems like that's causing the reload for app with sidemenu's & tab pages... this.navCtrl.pop() / this._navCtrl.navigateBack('HomeScreen'), and then call exitApp.
NOTE: Tabs & SideMenu as those have its own routing module does create lot of complexity with app navigation.
Solved:
As Mention by #rtpHarry template of SideMenu / Tabs have History which leads application to Reload it self on root page. i was able to solve this by clearing History.
ionViewDidEnter(){
navigator['app'].clearHistory();
}
on Your Root Page just Clear your history and your Hardware Back Button will close the Application instead of Reloading it.
Do you have a sidemenu in your app? I'm just curious because this seems to be when I get this problem as well.
If you look in your inspector, you will see that window.history has a length of 1.
I don't see it in some of my apps, but the app that I have a side menu setup acts this way - on the homepage if you press back the screen goes white then it reloads the app.
Like I say, looking in the inspector shows that there is a history to step back to, which it is trying to do, and whatever that history step is, it just pushes it forward back to the homepage, which made me wonder if it was the sidemenu setting up its own control of the navigation system.
I've probably said some poorly worded terminology but as I haven't solved this myself I thought I would just let you know what I had found... hopefully it helps you move forward.
In my scenario, I wasn't even trying to do the exit on back code - I just noticed that the app would appear to "reboot" if I kept pressing back.
This explain the solution on Ionic 5 (and 4.6+ too I think).
private backButtonSub: Subscription;
ionViewDidEnter() {
this.backButtonSub = this.platform.backButton.subscribeWithPriority(
10000,
() => {
// do your stuff
}
);
}
ionViewWillLeave() {
this.backButtonSub.unsubscribe();
}
also keep
IonicModule.forRoot({
hardwareBackButton: true
}),
to true (default) in your app.module.ts
Sources:
https://www.damirscorner.com/blog/posts/20191122-CustomizingAndroidBackButtonInIonic4.html
The Doc
We noticed the Pin It button is no longer working within our application. Pressing it doesn't result in anything occurring.
The PinItListener doesn't get any exception callbacks, but it returns false for whether it was pinned in onComplete.
Trying out the PinItDemo project bundled with the SDK, nothing occurs on click either. I tried it with our client ID and a new client ID I set up.
Since it stopped functioning between releases of our application, I'm assuming it's a Pinterest change. Did a Pinterest update break the PinItSDK? Is there something we can do to fix it?
I'm not sure if PinItSDK doesn't work anymore or what the problem is. But there is another way you can pin the content. You can use the base url to open Create Pin form like
http://www.pinterest.com/pin/create/button/?media=http://www.ournorthstar.com/wp-content/uploads/2013/10/test1.jpg&title=Sample&description=This+is+a+test+description
and pass it as an intent and start the activity.
Eg:
String shareUrl = "http://www.pinterest.com/pin/create/button/?media=http://www.ournorthstar.com/wp-content/uploads/2013/10/test1.jpg&title=Sample&description=This+is+a+test+description"
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(shareUrl));
startActivity(myIntent);
This issue was fixed in Pinterest for Android 2.1.4
I am now working with Android UiAutomator on for UI Test on my Android app. My app has a function that requires the user to verify the email to continue, so I try to do it like this: after reach to that function -> getUiDevice.pressHome -> Browser -> try to log in email -> PressHome again -> Press RecentApps then I stuck here, I cannot press on my Apps to return to it again. I try another way by clicking on my App icon but it starts my app again, not at the state before. Can anyone suggest me a solution for this? Any help is appreciate.
Thanks in advance.
Try this :
UiObject appBackground = new UiObject(new UiSelector().description("ABC"));
appBackground.click();
It did not show any description through 'uiautomatorviewer' command but this worked for me.
I could manage to create this behavior with:
fun backgroundAndForeground() {
val device = UiDevice.getInstance(getInstrumentation())
device.pressHome()
// Pressing app switch two times makes the last app put on background come to foreground.
device.pressKeyCode(KeyEvent.KEYCODE_APP_SWITCH)
device.pressKeyCode(KeyEvent.KEYCODE_APP_SWITCH)
}
In this case, I think that android only resume app when clicking the recent app image. It does not work on clicking display text or app icon. So, we need to click image of your app in recent app list. At that time you need to write as below. I always do that for similar case.
// Take all image view by class type and click by instance no.
new UiObject(new UiSelector().className("android.widget.ImageView").instance(3)).click();
You need to count instance no of your recent app image view. Not app icon image in recent app scroll view. Please try this. Thanks.
I've spent half a day on this and concluded I needed to issue a device.click(). Since my use-case is that my app was the last one running (not switching to the browser like you), I can safely click the middle of the screen and it'll always work.
If you're the 2nd to last running app, you can probably do x: 0 and y: device.displayHeight/2.
I've not tested this on many operating systems, only 9.