Search code examples
androidurlstreamflash-cs6

I need help linking an app to another and opening a URL


I really need help with an android application that I am trying to make for my personal use.

I want to use adobe flash pro. I can make the GUI, but I just need the code that makes it all work.

This is my intention: When I click on a button, it opens another app (vplayer or MX Player) and then the player opens an RTMP stream.

basically, i want my app to open a URL with another app.

Please help me with this.

Thank you.


Solution

  • You can use the below code:

    Assumptions:

    • hope you are looking for code in java.
    • You have an ImageButton on your screen whose id is imageButton1
    • You have an URL ready before calling this code.

    Code Explanation:

    A reference to the ImageButton is created and an on click listener is set for it. we use Intent and set the URL as its data. now, Onclick will fire an Intent which will be handled by any app on the android system capable of handling that data.

    ImageButton my_icon= (ImageButton) findViewById(R.id.imageButton1);
    
        my_icon.setOnClickListener(new OnClickListener() {
    
            @Override
            public void onClick(View v) {
    
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(url));
                startActivity(intent);
    
            }
        });