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 paramètres du systéme
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "imap");

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

// Récupère 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: Après 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 paramètres du systéme
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "imap");

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

// Récupère 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 très bien avec la console java !!!

Problème, 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


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to