BroadcastReceiver for a Service to catch broadcast Intent ACTION_BOOT_COMPLETED

by Jean-Baptiste Queru » Fri, 27 Feb 2009 23:47:29 GMT


Sponsored Links
 You need to do it in your manifest, since at the point where
boot_completed is sent none of your app code can possibly have run to
register a listener.

Be aware that boot_completed is a point where the system is under
heavy load/contention - be sure to keep your onReceive function as
short as it can possibly be (specifically, avoid I/O if at all
possible).

JBQ






-- 
Jean-Baptiste M. "JBQ" Queru
Android Engineer, Google.

Please don't contact me directly.

--~--~---------~--~----~------------~-------~--~----~



BroadcastReceiver for a Service to catch broadcast Intent ACTION_BOOT_COMPLETED

by Jean-Baptiste Queru » Sat, 28 Feb 2009 00:48:13 GMT


 ou should remove
android:permission="android.permission.RECEIVE_BOOT_COMPLETE" from
your receiver tag:

-you have a typo in it.

-what that really means is "I want the sender to hold that
permission", which isn't what you meant, and is probably what prevents
your code from working.

JBQ

On Fri, Feb 27, 2009 at 8:33 AM, Graeme <graeme.br...@btinternet.com> wrote:



--
Jean-Baptiste M. "JBQ" Queru
Android Engineer, Google.

Please don't contact me directly.

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


BroadcastReceiver for a Service to catch broadcast Intent ACTION_BOOT_COMPLETED

by Marco Nelissen » Sat, 28 Feb 2009 01:18:53 GMT


 


That should be "android.intent.action.BOOT_COMPLETED"

--~--~---------~--~----~------------~-------~--~----~



BroadcastReceiver for a Service to catch broadcast Intent ACTION_BOOT_COMPLETED

by Marco Nelissen » Tue, 03 Mar 2009 00:15:38 GMT


 


No, you should not include
'android:permission="android.permission.RECEIVE_BOOT_COMPLETED"' in
your receiver, for the reasons JBQ explained.

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Issue to connect at IMAP4 server with Anrdoid

Hi everybody

I have a project, it's to connect Android at IMAP4 serveur with
eclipse.
.

Here my .java file:



package com.connectionimapandroid;

import java.util.Properties;

import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Store;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class ConnectImapAndroid extends Activity {
/** Called when the activity is first created. */

private static final String TAG = "MyActivity";

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.main);


String host="....", username="......", password="......";

// initialisation des paramtres du systme
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "imap");

// Spcification du serveur mail IMAP
props.put("mail.imap.port", "143");
props.put("mail.imap.host", host);

// Rcupre la session
Session session = Session.getDefaultInstance(props, null);
try{
// Get a Store object
Store store = session.getStore("imap");
Log.v(TAG, "Connection: Avant le store.connect");
// Connection au serveur IMAP
store.connect(host, username, password);
Log.v(TAG, "Connection: Aprs le store.connect");

// Close the Store
store.close();
}
catch(MessagingException mex) {
//mex.printStackTrace();
Log.e(TAG, "Connection: Exception Error=" + mex);
}
}

}


Next I add on the next ligne under the AndroidManifest.xml file to do
note have  permission denied (maybe missing INTERNET permission):
<uses-permission android:name="android.permission.INTERNET" />

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.connectionimapandroid"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/
app_name">
<activity android:name=".ConnectImapAndroid"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>

My code run in the consol java but note in android

package test;


import java.util.Properties;

import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Store;





public class ImapClient
{
public static void main(String[] args){
String host="129.227.81.35", username="33646111214",
password="5034207548944431280";

// initialisation des paramtres du systme
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "imap");

// Spcification du serveur mail IMAP
props.put("mail.imap.port", "143");
props.put("mail.imap.host", host);

// Rcupre la session
Session session = Session.getDefaultInstance(props, null);
try{

// Get a Store object
Store store = session.getStore("imap");

// Connection au serveur IMAP
store.connect(host, username, password);

System.out.println("CONNECTION REUSSI ");


// Close the Store
store.close();
}
catch(MessagingException mex) {
System.out.println("Failed, exception: " + mex);
}
}
}



Et a fonctionne trs bien avec la console java !!!

Problme, avec l'mulateur d'android (affichage sur l'mulateur
android) il me met une erreur:

The application Connection Imap Android (process
com.connectionimapandroid) has stopped unexpectedly. please try again

Error here in the Log window :


7-15 12:32:46.328: ERROR/dalvikvm(863): Could not find method
javax.activation.DataHandler.getName, referenced from method
javax.mail.internet.MimeUtility.getEncoding
07-15 12:32:46.328: WARN/dalvikvm(863): VFY: unable to resolve virtual
method 1819: Ljavax/activation/DataHandler;.getName ()Ljava/lang/
String;
07-15 12:32:46.328: WARN/dalvikvm(863): VFY:  rejecting opcode 0x6e at
0x0004
07-15 12:32:46.328: WARN/dalvikvm(863): VFY:  rejected Ljavax/mail/
internet/MimeUtility;.getEncoding (Ljavax/activation/DataHandler;)
Ljava/lang/String;
07-15 12:32:46.328: WARN/dalvikvm(863): Verifier rejected class Ljavax/
mail/internet/MimeUtility;
07-15 12:32:46.328: DEBUG/AndroidRuntime(863): Shutting down VM
07-15 12:32:46.328: WARN/dalvikvm(863): threadid=3: thread exiting
with uncaught exception (group=0x4000fe70)
07-15 12:32:46.338: ERROR/AndroidRuntime(863): Uncaught handler:
thread main exiting due to uncaught exception
07-15 12:32:46.349: ERROR/AndroidRuntime(863): java.lang.VerifyError:
javax.mail.internet.MimeUtility
07-15 12:32:46.349: ERROR/AndroidRuntime(863):     at
com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:116)
07-15 12:32:46.349: ERROR/AndroidRuntime(863):     at
com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:578)
07-15 12:32:46.349: ERROR/AndroidRuntime(863):     at
javax.mail.Service.connect(Service.java:291)
07-15 12:32:46.349: ERROR/AndroidRuntime(863):     at
javax.mail.Service.connect(Service.java:172)
07-15 12:32:46.349: ERROR/AndroidRuntime(863):     at
com.connectionimapandroid.ConnectImapAndroid.onCreate
(ConnectImapAndroid.java:48)
07-15 12:32:46.349: ERROR/AndroidRuntime(863):     at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1123)
07-15 12:32:46.349: ERROR/AndroidRuntime(863):     at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2231)
07-15 12:32:46.349: ERROR/AndroidRuntime(863):     at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2284)
07-15 12:32:46.349: ERROR/AndroidRuntime(863):     at
android.app.ActivityThread.access$1800(ActivityThread.java:112)
07-15 12:32:46.349: ERROR/AndroidRuntime(863):     at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
07-15 12:32:46.349: ERROR/AndroidRuntime(863):     at
android.os.Handler.dispatchMessage(Handler.java:99)
07-15 12:32:46.349: ERROR/AndroidRuntime(863):     at
android.os.Looper.loop(Looper.java:123)
07-15 12:32:46.349: ERROR/AndroidRuntime(863):     at
android.app.ActivityThread.main(ActivityThread.java:3948)
07-15 12:32:46.349: ERROR/AndroidRuntime(863):     at
java.lang.reflect.Method.invokeNative(Native Method)
07-15 12:32:46.349: ERROR/AndroidRuntime(863):     at
java.lang.reflect.Method.invoke(Method.java:521)
07-15 12:32:46.349: ERROR/AndroidRuntime(863):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:782)
07-15 12:32:46.349: ERROR/AndroidRuntime(863):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
07-15 12:32:46.349: ERROR/AndroidRuntime(863):     at
dalvik.system.NativeStart.main(Native Method)



So now Android emulator say :

The application Connection Imap Android (process
com.connectionimapandroid) has stopped unexpectedly. please try again


I'm don't know what I have to do !!

Thanks

dany


--~--~---------~--~----~------------~-------~--~----~

2. Wrapping AndroidService with a package

Hi all,

I have a use case, an *Android Service is wrapped by a Java package
containing the Init.java class*.

The Applications (Activity) should import the package and instantiate the
Init class.
and work on it.

The bindService is called in the constructor of the Init class.

*My problem here is:*
The instantiation happens immediately returning an object of Init class, but

binding with the Service is not.

*I observe that:**
*1). If i do this way
*    onCreate() {
**        Init service = new Init(this);        //Instantiating and binding
       service.create();                        //Calling a method in the
Init which requires a service connection handle
    }
*The call fails As the Service connection handle is not prepared yet

2). The onServiceConnection is getting called only if there is an event on
the UI
like button click or list item selection.

*I would Like to know:**
*1). What exactly happens between the *
         bindService and onServiceConnected *calls
2). Is there any way that we can push the request to call onServiceConnected
immediatly after bindService.
So that i can use the above shown use case.

Any Suggestion, pointers would be really helpful.

-- 
Shine bright,
(: Naveen Krishna Ch :)

--~--~---------~--~----~------------~-------~--~----~

3. help me with dynamic element generation

4. Failed to launch the android under the emu

5. quick change input language in android

6. TabHost Listview dissapearing after going to SMS screen and back.

7. complete action using