Context:
We have created an application which can be started by any of the following operations:
- When we click on the Application's icon.
- When we receive a broadcast that is listened by our Application.
- Deeplink of any activity of our Application.
- The activity Screens are exposed outside of application too, like widgets, clicking on any of the activity screens.
- Scheduled periodic job restarting application in case it was killed.
Use Case: I want a way to differentiate between Case 2, 5 from other case because for other 3 scenarios' we will get onCreate of some application's activity.
But for case 2 when we get a broadcast, it doesn't start any activity, it just calls some services and stores some data.
Is there a way I can identify whether this has happened or not?
Why do we want to do this? We are actually working on testing the fully drawn time (latency) of our different activities for different scenarios. For all the activities, we are starting from onCreate of the activities and closing the timer at fullyDrawn, but for the Broadcast calls, we can not identify that Application is already started.
Question: How can we differentiate if an application is started by an activity or by some broadcast or periodic jobs?
We tried adding some singleton Boolean in onCreate of Application and onCreate of Activity, using this we can identify that application is called because of activity, but still this doesn't help with identifying what if Application was created earlier even before the activity's flow was triggered?
If that helps I will share some dummy code, please let me know.
Thank you
1条答案
按热度按时间4c8rllxm1#
1.使用
putExtra()
方法放置来自启动Intent的额外信息,并分别使用getIntent()
和onStart()
获取Activity和服务的值。您可以在putExtra()
方法中传递启动Activity的名称。在接收Activity/服务中,将从Intent接收到的值附加接收器类名,并将其存储在本地或远程。您必须检查所有类中的Intent值。或
1.使用Google Analytics记录事件。