Forum Xamarin.Android

How to open another installed app with a onclick listener

Hello I am working on a app that has a tools button that has a button that has a onclick value assigned to it my question is how do I have it open another i have installed on the device I know how to do this in java but need to know how to do it in Xamarin

here's my button layout code:

<Button
            android:text="Tools"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/button1"
            android:onClick="tools" />

here's my c# code to the button:

 //Code That Opens The Tools App!

    [Java.Interop.Export("tools")] // The value found in android:onClick attribute.
    public void btnOneClick2(View v) // Does not need to match value in above attribute.
    {
        var intent = new Intent(Android.Content.Intent.ActionSend);
        var uri = Android.Net.Uri.Parse("com.d4a.toolbelt");
        StartActivity(intent);
    }

the com.d4a.toolbelt is the package name of the app i'm trying to open.

any help would be amazing!

Thank you in advance

Answers

  • ChrisDeBrodie.OAChrisDeBrodie.OA USUniversity ✭✭
    edited August 2015

    I Got it working using the following code:

     [Java.Interop.Export("tools")] // The value found in android:onClick attribute.
            public void btnOneClick2(View v) // Does not need to match value in above attribute.
            {
                var intent = PackageManager.GetLaunchIntentForPackage("packagenamehere");
                StartActivity(intent);
            }
    

    I hope this helps someone else :smile:

  • mohsinkhanmohsinkhan USMember ✭✭

    i want to open flipkart on my button click what i do?

Sign In or Register to comment.