get v4.app.FragmentManager from Flutter Plugin - android

i try to get FragmentManager in my android flutter plugin. In my case i need v4.app.FragmentManager.
but in PluginRegistry Registrar. i just get app.FragmentManager from Registrar.activity().fragmentManager
Since i use FlutterFragmentActivity which extend v4.app.FragmentActivity, you can see the code in here.
So i think it's possible to get v4.app.FragmentManager().
anyone have idea how to reach that ?

finally, i solve this problem with simple fact:
First, Registrar.activity is app.activity which is if you want to get fragment manager you only get app.FragmentManager. So we can't call getSupportFragmentManager() function to get v4.app.FragmentManager.
Second, FlutterActivity / FLutterFragmentActivity is extending v4.app.Activity / v4.app.FragmentActivity so we can use getSupportFragmentManager() in this case.
So simply in Flutter Android plugin I just declare Activity / FragmentActivity equals with what MainActivity extended like. After that I can use getSupportFragmentManager() to get v4.app.FragmentManager. the code like below :
v4.app.Activity act = (Activity)vRegistrar.activity();
v4.app.FragmentManager = act.getSupportFragmentManger();
Hope it's helpful. Thanks...

Related

Android status bar show in Unty

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).

It is possible to show page in own activity in Xamarin.Forms on Android?

I want to navigate between pages be starting and finishing new activity for any new page and show this page in own activity. How to achieve this behavior?
The answer is Yes,you could look at Native Forms.
For ios:
in ios project AppDelegate
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
Forms.Init();
...
UIViewController mainPage = new NotesPage().CreateViewController();
mainPage.Title = "Notes";
_navigation = new AppNavigationController(mainPage);
_window.RootViewController = _navigation;
_window.MakeKeyAndVisible();
return true;
}
For Android:
in Android project your activity ,it convert your page to a fragment,and then you could fill it in your activity:
Android.Support.V4.App.Fragment mainPage = new NotesPage().CreateSupportFragment(this);
SupportFragmentManager
.BeginTransaction()
.Replace(Resource.Id.fragment_frame_layout, mainPage)
.Commit();
On Android Xamarin.Forms navigate among pages by using Fragments.
If you don't like it you may fork Xamarin.Forms and change the code to work the way you want it to work: https://github.com/xamarin/Xamarin.Forms
This will make some packages incompatible with your fork of Xamarin.Forms, which you may need to take under consideration if you intend to use them.
Also if you consider the required time and knowledge this is non-trivial. It is highly unlikely that someone will do that job instead of you and provide you with the plug-in solution.

Trouble instantiating gdx-pay purchaseManager in my game

I am trying to set up gdx-pay in my game. I have followed the official readme (https://github.com/libgdx/gdx-pay/), but can't seem to instantiate the PurchaseManager in my AndroidLauncher.
I have set up a class that handles PurchaseManager installation, but every time I try to instantiate it in the AndroidLauncher I get this error:
"java.lang.RuntimeException: Unable to start activity ComponentInfo{appPackage.AndroidLauncher}: java.lang.IllegalArgumentException: Support for pending purchases must be enabled. Enable this by calling 'enablePendingPurchases()' on BillingClientBuilder."
The readme says to add this to the AndroidLauncher onCreate
game.purchaseManager = new PurchaseManagerGoogleBilling(this);
The problem is that I have to add this
ProjectName.purchaseManager = new PurchaseManagerGoogleBilling(this);
This give me an error saying that I have to make purchaseManager static in my ProjectName class
When I do this, I get the RuntimeException mentioned above.
The sample gdx-pay project instantiates PurchaseManager with this code
public class AndroidLauncher extends GenericAndroidLauncher {
#Override
protected void initFlavor(GdxPayApp game) {
super.initFlavor(game);
game.purchaseManager = new PurchaseManagerGoogleBilling(this);
}
}
When I try this, #Override is invalid and initFlavor does not exist. I tried looking for initFlavor in the gdx-pay files, but had no luck finding anything...
Thanks for taking the time to help
Well it turns out that the following line in my android gradle was the issue
implementation 'com.android.billingclient:billing:2.0.1'
Gdx-pay takes care of this automatically and uses client 1.1
Setting the billingclient to 2.0.1 was the problem. I was able to fix it by deleting that line. Big thanks to the libGdx discord guys!

Instabug map is not available in screenshot

This is the code where I add the map to instabug:
Log.i("","entered here... map:" + mMap + "...." + mMapFragment.getView());
PSLocationCenter.getInstance().instabug.addMapView(mMapFragment.getView(), mMap);
Where I get this log:
04-01 14:28:55.455: I/(26117): entered here... map:com.google.android.gms.maps.GoogleMap#5091193....android.widget.FrameLayout{7dbac34 V.E...C.. .......D 0,0-1080,1776}
As you can see. my map exists, and also the fragment. The initMap function is in the BaseActivity, and other classes to have the map inside instabug.
This is my map:
And this is what I see in instabug:
In Instabug we hold WeakReference<GoogleMap> so can you try switching the GoogleMap variable to a global variable in your class and tell me how it goes?
I've also noticed you're using v1+ of Instabug, I'd recommend using v2 as it contains a lot of bug fixes and enhancements aside from the UI rehall and the new features :)
And please don't hesitate to contact us on our support channels through the website anytime.
This issue has been solved since version 3.0.0.
You just need to upgrade to latest version >= v3.0.5

Xamarin Android Google Map v2 SetOnCameraChangeListener Method

I am working on android map app in xamarin android. I want to handle the zoom event of map. Can anybody tell me how can I do this in xamarin android using map.SetOnCameraChangeListener ..
Regards
This is a bit late of an answer, but this really helped me. Should have everything you need.
http://pastebin.com/dgdiDk2N
Basically you need to implement the interface:
public class MapTab : Fragment, GoogleMap.IOnCameraChangeListener
Then you can set the listener as such:
map.SetOnCameraChangeListener (this);
And you will also need to add the method OnCameraChange:
public async void OnCameraChange (CameraPosition cameraPos)
{
//Do your things here when the camera updates
}

Categories

Resources