I created a new activity which extends SingleTabActivity and it calls:
getActivityTab().loadUrl(new LoadUrlParams("http://google.com.vn", PageTransition.AUTO_TOPLEVEL));
But nothing is showing up. Do I need anything else to tell Chromium to render web content?
Thank you!
I found the answer. Override finishNativeInitialization and add following lines:
LayoutManager layoutDriver = new CustomTabLayoutManager(getCompositorViewHolder());
initializeCompositorContent(layoutDriver, findViewById(org.chromium.chrome.R.id.url_bar),
(ViewGroup) findViewById(android.R.id.content),
(ToolbarControlContainer) findViewById(org.chromium.chrome.R.id.control_container));
Related
I am trying to implement ExoPlayer-Wrapper for NativeScript Android like this:
I have created a custom view using Placeholder
<Placeholder (creatingView)="createNativeView($event)"></Placeholder>
In TS:
public createNativeView(args: CreateViewEventData) {
let exoPlayerView = new com.google.android.exoplayer2.ui.SimpleExoPlayerView(args.context);
let mExoPlayerHelper = new net.alexandroid.utils.exoplayerhelper.ExoPlayerHelper.Builder(args.context, exoPlayerView)
.setUiControllersVisibility(true)
.setAutoPlayOn(true)
.setVideoUrls("http://cdn-fms.rbs.com.br/vod/hls_sample1_manifest.m3u8")
.setTagUrl("http://google.com")
.createAndPrepare();
args.view = exoPlayerView;
}
But I didn't get any success or error message. APP got exit instantly after start. Any suggestion please?
Found my mistake https://github.com/Pulimet/ExoPlayer-Wrapper/blob/5476adf07e71105a009a6fc643daeb54b7a1f953/exoplayerhelper/src/main/java/net/alexandroid/utils/exoplayerhelper/ExoPlayerHelper.java#L204
'String[] urls'. So, url will be array type like this:
.setVideoUrls(["http://cdn-fms.rbs.com.br/vod/hls_sample1_manifest.m3u8"])
I have used Ampiri integration in my app.
I copy paste all the code from their android sdk integration wizard for banner ads into my code. What bothers me is that Android Studio can not find that listener and view in the red letter.
So what is that I miss? Is there any problems on my code? If not what should I do to resolve this issue? Please help me.
Following is my code:
I’ve implemented the AdEventCallback using:
import com.ampiri.sdk.listeners.AdEventCallback;
and call it from main activity inside onCreate as describe in my code below:
public abstract class MainActivity extends AdCallbackActivity implements AdEventCallback {...}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FrameLayout adView = (FrameLayout)view.findViewById(R.id.ad_view);
StandardAd standardAd = new StandardAd(this, adView,“MY_ADUNIT_ID",BannerSize.BANNER_SIZE_320x50, adListener);
standardAd.loadAd();
Please check my comments inline for each error.
view.findViewById(R.id.ad_view)
If the ad_view is in the current Activity layout set by setContentView, you don't need to add "view."
i.e.
findViewById(R.id.ad_view)
adListener
Please implement an event listener interface AdEventCallback, referencing to our integration page.
In addition, If you will have the AdEventCallback methods in your AdCallbackActivity.java file.
please try the code below.
StandardAd standardAd = new StandardAd(
this, adView, "3dfbb889-3bcd-4c34-82ae-8fcb539c3b25",
BannerSize.BANNER_SIZE_320x50, this);
If it doesn't work, please send me your MainActivity and AdCallbackActivity to suppport#ampiri.com.
I work with Xamarin Forms. My Android activity extends FormAppCompatActivity. I use a MasterDetailPage and this.Detail is init with new NavigationPage(new PagePerso()). I have a xamarin.forms.view and its renderer to Android.
I would like put this inside the NavigationBar (ActionBar to Android).
I tried to use a NavigationPageRender. Then I tried to use :
protected override void OnElementChanged(ElementChangedEventArgs<NavigationPage> e){
base.OnElementChanged(e);
Android.Views.View actionBar = base.ViewGroup.GetChildAt(0);
...}
Thanks you in advance for your help !
If you have an other solution, suggest me ! (I use Xamarin forms, FormAppCompat, MasterDetailPage and NavigationPage to its Detail)
Solution and new problem :
I have finally come to add an Android.View inside ActionBar using ViewGroup. Now, my problem is that I want to add a custom view (xamarin) ...
Android.Widget.Button bt = new Android.Widget.Button(base.ViewGroup.Context);
ViewGroup actionBar = (ViewGroup) base.ViewGroup.GetChildAt(0);
actionBar.AddView(viewGroup);
The button with this code is added well.
So I have MyCustomView view = new MyCustomView();
And I would like add view as viewGroup previously but it's not an Android.Views.View.
Thanks you in advance !
Have you tried actionBar.SetDisplayShowCustomEnabled(true);?
I have recently seen some inconsitencies with this approach using AppCompat that I'm about the report to Xamarin.
I have an axml page called Main.axml and a MainActivity.cs file ,i collect values from textbox in axml page and update it in database using web services after updating the database i want to move to a an axml page which just displays the text "Thank you for entering the data".Can anyone please tell how to navigate to another axml page from MainActivity.cs
i tried this in windows mobile app ,but it is not working for Xamarin android :
this.NavigationService.Navigate(new Uri("/Thanks.xaml", UriKind.RelativeOrAbsolute));
Thanks #Artur Shamsutdinov for the link to the article.For anyone who wants to skip reading the article .Please find below the code we have to use in our Activity Page,
var intent = new Intent(this, typeof(ThankyouActivity));
StartActivity(intent);
in ThankYouActivity.cs we can use this code to show the axml page,which will then show thankyou.axml on screen
SetContentView(Resource.Layout.thankyou);
You can also use the following short way:
StartActivity(typeof(ThankyouActivity));
You can use it:
Button thankYou = FindViewById<Button>(Resource.Id.btnThankYou);
thankYou.Click += delegate { StartActivity(typeof(ThankYouActivity)); };
In Xamarin, I have pasted the following code from a working activity into a blank new activity:
[Activity (Label = "SimpleOnePageViewPager", MainLauncher = true)]
public class MainActivity : FragmentActivity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.Main);
FragmentItem fragItem = new FragmentItem ();
List<Android.Support.V4.App.Fragment> fragments = new List<Android.Support.V4.App.Fragment>();
fragments.Add(fragItem);
ViewPagerAdapter pageAdapter = new ViewPagerAdapter(SupportFragmentManager, fragments);
var pager = FindViewById<ViewPager>(Resource.Id.MainViewPager);
pager.Adapter = pageAdapter;
}
}
This is the error that I am getting?
Error CS0103: The name 'Resource' does not exist in the current context
Can I please have some help with this code?
Thanks in advance
Make sure you added namespace using Project_Name;
I had this problem too, and solved with this steps:
Open MainActivity.cs of the Android project and put the line:
using AppName.Droid
This line is the name of namespace in the file Resource.designer.cs
You can change the MainActivity.cs Build Action property as 'none' instead of 'compile'. I Hope this will resolve your problem.
Thanks,
Imman
It was exactly the problem that I just solved, I think that this is a Xamarin Bug, when you add an existing xaml file it add it to the project without set it as embedded resource as it should be, and without set the custom tool command that must be set to: MSBuild:UpdateDesignTimeXaml
I met same problem today. I searched around, and also tried above solutions, but it did not work from my side.
I already resolved the problem by myself with bellow steps:
Update xamarin nuget packages
Clean and rebuild the project
P/S: hope it can help others if they meet same problem.
Happy coding!