Android one app launches another app

Recently, an app started another app. This game is very popular. Have you tried to update QQ to version 5.1? Other apps can be added to QQ health to jump from QQ to other app applications. This is fun. How much traffic has it brought all at once.

1、 Let's start with a few lines of code. One app starts another app

There may be many similar codes on the Internet. Let's mention it to let you know the process.

2、 How to get parameters for the launched app?

In the opened app application, the parameter information can be received in a few lines of code. If the bundle here is empty, it means that it does not jump over. It may be that the user clicks the desktop icon to open the app, so there must be no parameter value. Let's play.

Wait, don't think it's over like this. What's more important is later: how to ensure that parameters can be received without a jump? This needs to be considered.

3、 Problem encountered: you can't get parameters every time you jump. Why?

After research, you must open the started activity every time to receive it, because the parameters passed are sent to the started activity (Android. Intent. Action. Main). How can you get the parameter data in other activities. Therefore, you must open the started activity first every time you jump over. This is a solution.

In order to ensure that the opened app enters the started activity every time, a welcome page (wellcomeactivity) is written here

Here, you can get the parameters every time. You can do what you want to do. You can save them to sharemamager or database and operate accordingly.

Then enter activity (mainactivity)

4、 Add the configuration of androidmanifest.xml

Pay attention to the configuration of the opened app. It's very critical. Please refer to the following

Starting an activity requires Android: launchmode = "singleinstance", and other activities require Android: launchmode = "singletop". This is better. If you have time, check the purpose of launchmode yourself. I won't talk about it here.

Demo download address: http://download.csdn.net/detail/lqw770737185/7903937

Address: http://www.cnblogs.com/liqw/p/3968340.html

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>