in Education by
Is there a way to know who is the application caller? These are several use cases cases: I have an application and a widget of it. Application is not running. Once I add/remove the widget, the system calls the application to run (Application.onCreate() is called and etc..). So I need to know that this is not a user who press an icon to run application, but this is a system needs to update widget. When I get low of memory, the system kills the application and then restors it again when there is enough memory. The question is the same as above. More similar cases... The only case that I can manage is a BootUpReceiver which is extended from BroadcastReceiver. Only in this case I am sure that the application is run by the "launch at start" feature. I need to know for sure - who (what service, receiver, intent, etc) any why is calling my application. Is there a way to know the caller source, or caller ID or any information about a service or any other who call my application to run? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
As @CommonsWare already mentioned: the better answer is to redesign your application such that you do not care why your code is being run. But actually you can get a general idea about why your application was called by dumping message query of MainLooper. You can use following code to do this: public static void dumpMainLooper(Context context) { Looper looper = context.getMainLooper(); try { looper.dump(new Printer() { @Override public void println(String s) { Log.d(LOG_TAG, "- " + s); } }, "AppMainLooperDump"); } catch (Throwable th) { Log.d(LOG_TAG, "App Main Looper error", th); } } You shouldn't use this code for any "logic" in your app, but you can use it for debugging and/or logging to get a general idea about Intents sent by system to your app to start it. You should call this method as early as possible, and in logs you will see something like this: Looper{41ff0388} mRun=true mThread=Thread[main,5,main] mQueue=android.os.MessageQueue@41ff03a8 Message 0: { what=100 when=-438ms obj=ActivityRecord{41ff43e0 token=android.os.BinderProxy@41ff3b78 {com.your.package/com.your.package.MainActivity}} } Message 1: { what=132 when=+9s911ms } (Total messages: 2) Message N - this is a messages which was send by the system to your app. Here you will see defferent messages and this messages should give you a general idea about callers of your app.

Related questions

0 votes
    My application crashes whenever my location is changed. Application structure is simple: there is one Activity and ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 8, 2022 in Education by JackTerrance
0 votes
    I have an app that was designed for the Google 2.2 api (it includes maps) and I want to make it ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    I'm designing a service that will comprise a cloud-based database (with a UI for us to manage the data), ... sit behind mobile apps. Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    I found the following piece of code from the adw launcher: Object service = launcher.getSystemService("statusbar ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 13, 2022 in Education by JackTerrance
0 votes
    Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    Error:Execution failed for task ':app:dexDebug'. com.android.ide.common.process.ProcessException: org.gradle. ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I made a website and turned it into Android app, using Phonegap website. I have files stored on a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 11, 2022 in Education by JackTerrance
0 votes
    I'm using SafetyNet API for checking if device is rooted or not and using the below helpful code but ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 19, 2022 in Education by JackTerrance
0 votes
    I want to know whether the user allows autostart permissions of the app. I have already tried this: ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 10, 2022 in Education by JackTerrance
0 votes
    I'm having a problem with my logcat since update 1.2 Beta for Android Studio. When I run my app ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 14, 2022 in Education by JackTerrance
0 votes
    I am creating an Android app that will download and cache PDF files (the files are for issues of ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I trying use Dungeons example in my app. In Android development guide it's written that I should confirm ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 20, 2022 in Education by JackTerrance
0 votes
    I trying use Dungeons example in my app. In Android development guide it's written that I should confirm ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    If I offload verification to a remote server, I think the process will be something like: Android Market Application Remote Server |-------- ... | | |-----nonce----->| | || | |...
asked Feb 9, 2022 in Education by JackTerrance
0 votes
    If I offload verification to a remote server, I think the process will be something like: Android Market Application Remote Server |-------- ... | | |-----nonce----->| | || | |...
asked Feb 5, 2022 in Education by JackTerrance
...