既に存在するアプリを開発していますが、学ぶためだけに開発しています。Android 用の GMail クライアント アプリを開発しています。Content Observer を試してみましたが、GMail Inbox の Content Provider URI を見つけることができませんでした。uaをクライアントに設定することで、別の方法を試しています。クライアントがセットアップされましたが、このクライアントをインスタンス化して GMail サーバーに接続する方法がわかりません。
以下は私のコードです:
GMailInbox.java
package com.tyco.gmailApp;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class GmailInbox extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//GmailObserver go = new GmailObserver();
//this.getApplicationContext().getContentResolver().registerContentObserver(Uri.parse("content://imap.gmail.com"), true, go);
Intent myService = new Intent(this,GMailService.class);
myService.putExtra("user", "rj@gmail.com");
myService.putExtra("password", "brooklyn");
startService(myService);
}
}
GMailService.java
package com.tyco.gmailApp;
import java.util.Properties;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.view.inputmethod.InputMethodSession;
import android.view.inputmethod.InputMethod.SessionCallback;
public class GMailService extends Service
{
private String mailhost = "imaps.gmail.com";
private String user;
private String password;
@Override
public IBinder onBind(Intent intent){
return null;
}
@Override
public void onCreate(){
super.onCreate();
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
this.user = intent.getStringExtra("user");
this.password = intent.getStringExtra("password");;
Properties props = new Properties();
props = System.getProperties();
props.setProperty("mail.store.protocol", "imaps");
props.setProperty("mail.imaps.host", mailhost);
props.put("mail.imaps.auth", "true");
props.put("mail.imaps.port", "993");
props.put("mail.imaps.socketFactory.port", "993");
props.put("mail.imaps.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
props.put("mail.imaps.socketFactory.fallback", "false");
props.put("mail.imaps.socketFactory.fallback", "false");
props.setProperty("mail.imaps.quitwait", "false");
// I Don't Know what to do here
}
}
すべての情報をプロパティ オブジェクトに収集した後、何をすべきかわかりません。何か提案してください。
よろしく、 ラフル・ジャイスワル