RikNorakomi
11/19/2015 - 4:45 PM

launch RFapp via browser or app

launch RFapp via browser or app

package nl.reclamefolder.rflauncherapp;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // launch app from this app
        findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent launchIntent = getPackageManager().getLaunchIntentForPackage("nl.onlineretailservice.reclamefolderandroid");
                launchIntent.putExtra("launchFromApp", true);
                launchIntent.putExtra("folderEditionID", 9196);
                launchIntent.putExtra("pageNumber", 8);
                startActivity(launchIntent);
            }
        });

        // launch RF app via browser
        findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String host = "launchApp";
                String folderEdition = "9196";
                String pageNumber = "4";

                Uri.Builder builder = new Uri.Builder();
                builder.scheme("reclamefolder")
                        .authority(host)
                        .appendQueryParameter("folderEditionID", folderEdition)
                        .appendQueryParameter("pageNumber", pageNumber);

                String url = builder.build().toString();
                Log.e("created url = ", url);

                Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                        Uri.parse(url));

                startActivity(browserIntent);
            }
        });


    }
}