How/when is PhoneApp instantiated in android - android

I've read in a few places that PhoneApp (com.android.phone.PhoneApp.java), is a "persistent process" which is "started early in the boot sequence." Can anybody explain exactly how and when this happens? Thanks.

Answering my own question....
The following entry in the AndroidManifest.xml file instructs the ActivityManager to start the specified activity.
<!-- Broadcast Receiver that will process BOOT Complete and launch OTA
-->
- <receiver android:name="OtaStartupReceiver" android:exported="false">
- <intent-filter android:priority="100">
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>

Related

Android TV (Emulator Preview, level L) - BroadcastReceiver does not work from manifest

I rely on broadcast send/receive for my app to work.
This code works perfectly on all platforms, but on latest Android Preview L, the broadcast is not received:
Intent intent = new Intent("com.my.BROADCAST_RECEIVED");
sendBroadcast(intent);
Receiver is registered in the manifest, as usual:
<receiver
android:name=".SimpleBroadcastReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.my.BROADCAST_RECEIVED" />
</intent-filter>
</receiver>
Note: if the receiver is registered in runtime (i.e. via registerReceiver(..)) - it does receive the broadcast.
Any information about this?
Found a different answer related to not receiving boot complete on SmartTv .
So as an act of despair I decided to give it a try and it worked!
Add a category tag to the intent filter. It's not documented anywhere:
<receiver
android:name=".SimpleBroadcastReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.my.BROADCAST_RECEIVED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
Hope this helps someone.

android receiver stops after clean ram

I have a gcm receiver, but it is not working before restarting phone and after clean memory. What should i change to guarantee receiver is always working?
<activity
android:name="com.example.diyet.MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.plugin.gcm.PushHandlerActivity"/>
<receiver android:name="com.plugin.gcm.CordovaGCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.plugin.gcm" />
</intent-filter>
</receiver>
<service android:name="com.plugin.gcm.GCMIntentService" />,
thanks in advance
if u want to start your receiver manually then use
registerReceiver(receiver) inside your activity
Sorry I don't know anything about GCM but if I get you right you have one of the following possibilities
If your GCMIntentService is custom, you can make this Service STICKY So the OS restarts it after a Crash. To do this you have to return return Service.START_STICKY; in your onStartCommand Method.
Also you can Register for the android.intent.action.BOOT_COMPLETED to get your Service started right after device is Booted.
If you want to prevent the Service to Crash, when the App Crashes you have to put it in another Thread. This can be achieved by Setting an custom Process Name in the Manifest
android:process="com.gigatronik.presenter.serialport.SerialPortListenerService"/
I will edit this answer, if you can give me more information on your Problem, since I never used GCM

Is it possible to run an activity or thread on receiving sms

Is it possible to Create an activity or thread with service which read incoming message text like if text=ab, start any activity, if text=abc, change audio manger setting,
check this article on how to handle sms.
in your manifest specify this:
<receiver android:name=".MyActivityIWhantToLaunch" android:exported="true" >
<intent-filter android:priority="1000">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>

Registering a Phonestate receiver after rebooting

I have implemented a receiver like this (in the manifest file)
<receiver android:name="com.phonelight.realparrot.RecorderBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE">
</action>
</intent-filter>
</receiver>
If the state of the phone changes, the recorder broadcast receiver is invoked.
Everything is fine. However, If I reboot the device, the receiver is never invoked until I run my application.
I need to register (not invoking) this receiver after booting.
Many thank,
[Edit]
I solved the problem by adding the following receiver to the Manifest file
<receiver android:name="com.phonelight.realparrotpro.RecorderBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
I did not register the RecorderBroadcastReceiver in the java code though.
I only added the above receiver. It means invoking anything from an app will register all the receivers written in the Manifest file.
You need to create a receiver for onBootComplete and then register your receiver there. This way your receiver will get registered even after reboot.
<receiver android:name="App_Receiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

How can I get Battery information in my app?

I tried to use a receiver to get Information about battery when received a system broadcast, but it failed without doing anything.
Here is the code:
if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction()))
{//doing
1...
}
and in AndroidManifest.xml
<receiver android:name=".BroadCastReceiver_battery">
<intent-filter>
<action android:name="android.intent.action.BATTERY_CHANGED" />
</intent-filter>
</receiver>
quasharou ,
I found this tutorial useful
Hope it helps .

Categories

Resources