dimanche 24 mai 2015

Start another application, then go back to the previous app, and it will change to next page

I would like my app could go to the other application by pressing a button by the following code:

public void go_other_app() {
        Button going= (Button) findViewById(R.id.go_to_other);

        going.setOnClickListener(new OnClickListener() {

            @Override

            public void onClick(View view) {

                Intent launchIntent = getPackageManager().getLaunchIntentForPackage("package name");
                if (launchIntent==null){
                    Toast.makeText(getApplicationContext(), "You haven't installed this app yet!", Toast.LENGTH_SHORT).show();
                }else{
                    startActivity(launchIntent);

                }
            }

        });

    }

Then when the user finishes stuff in this secondary app, he backpress to leave it and go back the previous app. But I would like him to immediately change to another activity without remaining the same activity. I only know the way to start a new activity by:

Intent i=new Intent(getBaseContext(),another_activity.class);
                    startActivity(i);

So it there a good way to fulfill my task? Thanks a lot!

Aucun commentaire:

Enregistrer un commentaire