ã¯ããã«
ãã®èšäºãæžããçç±ã¯ãAndroidã·ã¹ãã çšã®ããã°ã©ã ãäœæããå¿ èŠãããããã§ãããã®ããã°ã©ã ã䜿çšããŠãååãŸãã¯ãµãŒãã¹ã®æ³šæãè¡ããããªã³ã©ã€ã³ã¹ãã¢ã®ææè ã«SMSã¡ãã»ãŒãžã®åœ¢åŒã§æ³šæããŒã¿ãéä¿¡ã§ããŸãã 以åãç§ã¯GSMã¢ãã ãšC ++ã§æžãããããã°ã©ã ãå«ãã·ã¹ãã ã䜿çšããŸãããããã¯ATã³ãã³ãã䜿çšããŠã¢ãã ãšglooxã©ã€ãã©ãªãšéä¿¡ããXMPPãä»ããŠã¡ãã»ãŒãžãåä¿¡ãããŠã§ããµã€ãåŽã§xmpphpã©ã€ãã©ãªã䜿çšããŠæ³šæããŒã¿ãéä¿¡ããŸããã ãã®ã¹ããŒã ã§ã¯ã泚æåä»ã·ã¹ãã ã24æéåäœãããããã³ã³ãã¥ãŒã¿ãŒãåžžã«ãªã³ã«ããŠããå¿ èŠããããŸããããã®ãããè¿œå ã®ãšãã«ã®ãŒæ¶è²»ãå€éã®ãã¡ã³ããã®ãã€ãºãã€ã³ã¿ãŒãããæ¥ç¶ã®åžžæç£èŠãè¡ãããŸããã
ãã®èšäºå šäœã§äœæããããã°ã©ã ã®äž»ãªã¿ã¹ã¯ã¯ã XMPPãããã³ã«ã䜿çšããŠç¹å®ã®åœ¢åŒã®ã¡ãã»ãŒãžãåä¿¡ããåä¿¡ããããŒã¿ãSMSã§è»¢éããããšã§ãã éçºç°å¢ã¯ã ADTãã©ã°ã€ã³ãšå¿ èŠãªSDKãã€ã³ã¹ããŒã«ãããEclipseã«ãªããŸãã XMPPãããã³ã«ãä»ãã察話ã«ã¯ã Androidããã€ã¹çšã®SMACKã©ã€ãã©ãªãŒã䜿çšãããŸãã
1. SMSãéä¿¡ãã
ãŸããã¢ããªã±ãŒã·ã§ã³ã®ãã¬ãŒã ã¯ãŒã¯ãäœæããŸãããã®åŸãå¿ èŠãªæ©èœãæ§ç¯ããŸãã ãããè¡ãã«ã¯ãEclipseã§ã次ã®ããŒã¿ã䜿çšããŠAndroidãããžã§ã¯ãïŒCtrl + N-Android-Android ProjectïŒãäœæããŸãã
æ°ãããããžã§ã¯ããäœæããåŸãSMSã¡ãã»ãŒãžãéä¿¡ããããã«å¿ èŠãªèš±å¯ïŒPermissionïŒãAndroidManifest.xmlãã¡ã€ã«ã«è¿œå ããŸãã ãããè¡ãã«ã¯ãEclipseéçºç°å¢ã§AndroidManifest.xmlãã¡ã€ã«ãéãã[Permissions]ã¿ãã«ç§»åããŠ[Add ...]ãã¿ã³ãã¯ãªãã¯ãã衚瀺ããããŠã£ã³ããŠã§[Uses Permission]ã¢ã€ãã ãéžæãã[OK]ãã¿ã³ãã¯ãªãã¯ããŠã解å床ãéžæããæ€çŽ¢ããŠéžæã§ããããã«ãªããŸãã¢ã€ãã android.permission.SEND_SMSãéžæããã¢ã¯ã·ã§ã³ãä¿åããŸãã ãã¹ãŠã®æäœåŸã[ã¢ã¯ã»ã¹èš±å¯]ã¿ãã¯æ¬¡ã®ããã«ãªããŸãã
ããã§ãããšãã°ãSMSã¡ãã»ãŒãžãéä¿¡ããæãç°¡åãªæ¹æ³ãèããŸããããã¯ãéåžžã®Androidãšãã¥ã¬ãŒã¿ãŒã§ãã¹ãã§ããŸãã ãããè¡ãã«ã¯ãAndroid Virtual Device ManagerïŒãŠã£ã³ããŠ-AVD ManagerïŒãšæ¬¡ã®ãã©ã¡ãŒã¿ãŒã䜿çšããŠã2ã€ã®æ°ããä»®æ³ããã€ã¹ãäœæããŸãã
äœæãããããžã§ã¯ãã®onCreateã¡ãœãã㧠ã次ã®ã³ãŒããè¿œå ããŸãã
package ru.blagin.xmppsmsgate; import android.app.Activity; import android.os.Bundle; import android.telephony.SmsManager; public class XMPPSMSGateActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage("5556",null,"Text SMS",null,null); } }
次ã«ãäž¡æ¹ã®Androidãšãã¥ã¬ãŒã¿ãŒãèµ·åããŸããåãšãã¥ã¬ãŒã¿ãŒã«ã¯SMSã¡ãã»ãŒãžã®éåä¿¡ã確èªããããã®ç¬èªã®çªå·ããããŸãããšãã¥ã¬ãŒã¿ãŒã®èµ·åãšåæåãå®äºããããçªå·5554ã®ãšãã¥ã¬ãŒã¿ãŒã§ã¢ããªã±ãŒã·ã§ã³ãå®è¡ããå¿ èŠããããŸããã¢ããªã±ãŒã·ã§ã³ã®èµ·ååŸãçªå·5556ã®ãšãã¥ã¬ãŒã¿ãŒãSMSã¡ãã»ãŒãžãåä¿¡ããŸãã
SMSã¡ãã»ãŒãžã®éä¿¡ã¯ãAndroidã·ã¹ãã ãSMSã¡ãã»ãŒãžã§å¿ èŠãªã¢ã¯ã·ã§ã³ãå®è¡ã§ããããã«ããSmsManagerã¯ã©ã¹ã䜿çšããŠå®è¡ãããŸããã ãã®ã¯ã©ã¹ã®ãªããžã§ã¯ããåæåããããã«ãéçã¡ãœããSmsManager.getDefaultïŒïŒã䜿çšãããŸããã SMSã¯sendTextMessageã¡ãœããã䜿çšããŠéä¿¡ãããŸããã¡ãœãããã©ã¡ãŒã¿ã¯æ¬¡ã®ãšããã§ãã
destinationAddress-ã¡ãã»ãŒãžã®éä¿¡å ã®çªå·ã
scAddress-ã¡ãã»ãŒãžãéä¿¡ãããã¢ãã€ã«ãªãã¬ãŒã¿ãŒã®SMSã»ã³ã¿ãŒçªå·ããã®ãã©ã¡ãŒã¿ãŒã®å€ããŒãã®å Žåãããã©ã«ãã®çªå·ã䜿çšãããŸãã
text -SMSã¡ãã»ãŒãžããã¹ãã
sentIntent -nullå€ã§ãªãå ŽåãPendingIntentãªããžã§ã¯ãããã®ãã©ã¡ãŒã¿ãŒã«æž¡ãããã¡ãã»ãŒãžã®éä¿¡çµæã«é¢ããã¡ãã»ãŒãžãåä¿¡ããŸãã
deliveryIntent -nullå€ã§ãªãå ŽåãPendingIntentãªããžã§ã¯ãããã®ãã©ã¡ãŒã¿ãŒã«æž¡ãããã¡ãã»ãŒãžé ä¿¡ã®çµæã«é¢ããã¡ãã»ãŒãžãåä¿¡ããŸãã
Androidãšãã¥ã¬ãŒã¿ãŒã¯ãã®ã¿ã¹ã¯ãå®å šã«åŠçããŸãããããã€ãã®å¶éããããŸããããšãã°ããã®äžã§ã¡ãã»ãŒãžé ä¿¡ã®çµæã確èªããããšã¯ã§ããŸããããã®ãããå°æ¥å®è¡ãããå®éã®ããã€ã¹ã䜿çšããå¿ èŠããããŸãã ãŸããsendTextMessageã¡ãœããã䜿çšããŠã¡ãã»ãŒãžãéä¿¡ããå Žåããã®é·ãã¯160æåãè¶ ããããšã¯ã§ããŸããã é·ãã¡ãã»ãŒãžã®å Žåã¯ãsendMultipartTextMessageã¡ãœããã䜿çšããå¿ èŠããããŸãããã®ã¡ãœããã¯ã160æåæªæºã®ã¡ãã»ãŒãžãéä¿¡ããããšãã§ããŸãã
äžèšã®äŸã§ã¯ãSMSã¡ãã»ãŒãžã®éä¿¡ãšåä¿¡è ãžã®é ä¿¡ã«é¢ããéç¥ãåä¿¡ããªããããå¿ èŠãªåŠçãè¿œå ããŠã¢ããªã±ãŒã·ã§ã³ã®æ©èœãæ¡åŒµããŸãã ãããè¡ãã«ã¯ãã¢ããªã±ãŒã·ã§ã³ã«ãããŒããã£ã¹ãã®æå³ã®2ã€ã®åä¿¡æ©ãç»é²ããå¿ èŠããããŸããããã«ãããå¿ èŠãªæå³ãåŠçããã察å¿ããããã¹ãã¡ãã»ãŒãžãç»é¢ã«è¡šç€ºãããŸãã
ãªãœãŒã¹ãšãã£ã¿ãŒã§ãã¡ã€ã³ã¢ããªã±ãŒã·ã§ã³ãŠã£ã³ããŠã«TextViewãŠã£ãžã§ãããè¿œå ããŠãç»é¢ã«æ å ±ã衚瀺ããŸãã
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:id="@+id/textView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="top|left"/> </LinearLayout>
å€æŽãè¡ã£ãåŸã®ã¢ããªã±ãŒã·ã§ã³ã³ãŒãã¯ã次ã®åœ¢åŒãåããŸãã
package ru.blagin.xmppsmsgate; import java.util.ArrayList; import android.app.Activity; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.telephony.SmsManager; import android.widget.TextView; public class XMPPSMSGateActivity extends Activity { TextView tv = null; String SENT = "SMS_SENT"; String DELIVERED = "SMS_DELIVERED"; private BroadcastReceiver sent = null; private BroadcastReceiver delivered = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // TextView tv = (TextView) findViewById(R.id.textView); // : IntentFilter in_sent = new IntentFilter(SENT); sent = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { tv.append(intent.getStringExtra("PARTS")+": "); tv.append(intent.getStringExtra("MSG")+": "); switch(getResultCode()) { case Activity.RESULT_OK: tv.append("SMS \n"); break; case SmsManager.RESULT_ERROR_GENERIC_FAILURE: tv.append(" \n"); break; case SmsManager.RESULT_ERROR_NO_SERVICE: tv.append(" \n"); break; case SmsManager.RESULT_ERROR_NULL_PDU: tv.append("Null PDU\n"); break; case SmsManager.RESULT_ERROR_RADIO_OFF: tv.append(" \n"); break; } } }; registerReceiver(sent, in_sent); // : IntentFilter in_delivered = new IntentFilter(DELIVERED); delivered = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { tv.append(intent.getStringExtra("PARTS")+": "); tv.append(intent.getStringExtra("MSG")+": "); switch (getResultCode()) { case Activity.RESULT_OK: tv.append("SMS \n"); break; case Activity.RESULT_CANCELED: tv.append("SMS \n"); break; } } }; registerReceiver(delivered, in_delivered); SendSMS("_"," > 160 ."); } // SMS public void SendSMS(String phone, String message) { SmsManager sms = SmsManager.getDefault(); ArrayList<String> al_message = new ArrayList<String>(); al_message = sms.divideMessage(message); ArrayList<PendingIntent> al_piSent = new ArrayList<PendingIntent>(); ArrayList<PendingIntent> al_piDelivered = new ArrayList<PendingIntent>(); for (int i = 0; i < al_message.size(); i++) { Intent sentIntent = new Intent(SENT); sentIntent.putExtra("PARTS", ": "+i); sentIntent.putExtra("MSG", ": "+al_message.get(i)); PendingIntent pi_sent = PendingIntent.getBroadcast(this, i, sentIntent, PendingIntent.FLAG_UPDATE_CURRENT); al_piSent.add(pi_sent); Intent deliveredIntent = new Intent(DELIVERED); deliveredIntent.putExtra("PARTS", ": "+i); deliveredIntent.putExtra("MSG", ": "+al_message.get(i)); PendingIntent pi_delivered = PendingIntent.getBroadcast(this, i, deliveredIntent, PendingIntent.FLAG_UPDATE_CURRENT); al_piDelivered.add(pi_delivered); } sms.sendMultipartTextMessage(phone, null, al_message, al_piSent, al_piDelivered); } @Override protected void onDestroy() { if(sent != null) unregisterReceiver(sent); if(delivered != null) unregisterReceiver(delivered); super.onDestroy(); } }
å®éã®ããã€ã¹ã§ã¡ãã»ãŒãžã®éä¿¡ããã¹ãããŠé ä¿¡éç¥ãåä¿¡ããã«ã¯ãç¬èªã®ã»ã«çªå·ã䜿çšããŠãããã¢ããªã±ãŒã·ã§ã³ãå®å šã«ãã¹ãã§ããŸãã 以äžã®å³ã¯ãé·ãã¡ãã»ãŒãžã®éåä¿¡ã瀺ããŠããŸãã
2. XMPPãããã³ã«ã§äœæ¥ããããã®ãµãŒãã¹ãäœæãã
次ã«ãXMPPãä»ããŠéä¿¡ããæ©èœãã¢ããªã±ãŒã·ã§ã³ã«è¿œå ããå¿ èŠããããŸãã ãããã®ç®çã®ããã«ãããã¯ã°ã©ãŠã³ãã§å®è¡ããããµãŒãã¹ïŒãµãŒãã¹ïŒãäœæããŸãã SMACKã©ã€ââãã©ãªãŒã䜿çšãããµãŒãã¹ã¯ãã¡ãã»ãŒãžãåä¿¡ããŠââåŠçããŸãã ããã«ããããŒããã£ã¹ãã®æå³ãå©çšããŠãåä¿¡ããã¡ãã»ãŒãžããã®ããŒã¿ã¯ãSMSãä»ãã衚瀺ããã³ãã®åŸã®éä¿¡ã®ããã«ãã¢ããªã±ãŒã·ã§ã³ã®ã¡ã€ã³ã¯ã©ã¹ã«è»¢éãããŸãã
ãµãŒãã¹ãã¢ããªã±ãŒã·ã§ã³ã«è¿œå ããã«ã¯ããµãŒãã¹ã®å®è£ ã¯ã©ã¹ãå®çŸ©ããå¿ èŠããããŸãããã®ããã«ã¯ãEclipseéçºç°å¢ã§ããããžã§ã¯ãããã±ãŒãžåãå³ã¯ãªãã¯ãã衚瀺ãããã¡ãã¥ãŒã§[æ°èŠ]ããã³[ã¯ã©ã¹]ãéžæããŸãã
衚瀺ããããŠã£ã³ããŠã§ãç»åã«ç€ºãããŠããå¿ èŠãªé ç®ãå ¥åãããå®äºããã¿ã³ãã¯ãªãã¯ããŸãã
ãããã®ã¢ã¯ã·ã§ã³ã®åŸãã¯ã©ã¹ã®å®è£ ããããžã§ã¯ãã«è¡šç€ºãããŸããAndroidManifest.xmlãã¡ã€ã«ã«ãµãŒãã¹ã¯ã©ã¹ãç»é²ããå¿ èŠããããŸãããã®ãããEclipseéçºç°å¢ã§ãã¡ã€ã«ãéãã[ã¢ããªã±ãŒã·ã§ã³]ã¿ãã«ç§»åãã[ã¢ããªã±ãŒã·ã§ã³ããŒã]ã»ã¯ã·ã§ã³ã®[è¿œå ]ãã¿ã³ãã¯ãªãã¯ãã衚瀺ããããŠã£ã³ããŠã§ããµãŒãã¹é ç®ãéžæããŸã[OK]ãã¿ã³ãã¯ãªãã¯ããŸãã ãµãŒãã¹ã®ã¯ã©ã¹åãæå®ããå¿ èŠããããšããã¹ãŠã®æäœã®åŸã[ã¢ããªã±ãŒã·ã§ã³]ã¿ãã¯æ¬¡ã®ããã«ãªããŸãã
次ã«ãã¢ããªã±ãŒã·ã§ã³ã«å¥ã®ã¢ã¯ã»ã¹èš±å¯ãè¿œå ããŠããªã³ã©ã€ã³ã«ã§ããããã«ããŸãããããè¡ãã«ã¯ãäžèšãšåãæé ã«åŸã£ãŠSMSã¡ãã»ãŒãžã®éä¿¡ãèš±å¯ããŸããä»åã®ã¿android.permission.INTERNETãéžæããŸãã
次ã®ã¹ãããã§ã¯ãSMACKã©ã€ââãã©ãªãŒãã¢ããªã±ãŒã·ã§ã³ã«è¿œå ãã httpïŒ//code.google.com/p/asmack/ã§ããŠã³ããŒããããããžã§ã¯ããã©ã«ããŒã«ä¿åããŠãããããžã§ã¯ãããããã£ãéããEclipseéçºç°å¢ã§ãããžã§ã¯ãåãå³ã¯ãªãã¯ããŸãã ã衚瀺ãããã¡ãã¥ãŒã§[ããããã£]ãéžæããŸãã ãããžã§ã¯ãèšå®ã®è¡šç€ºããããŠã£ã³ããŠã§ãå·ŠåŽã®ãªã¹ãã§ãJavaãã«ããã¹ãé ç®ãéžæãããå€éšJARã®è¿œå ...ããã¿ã³ãã¯ãªãã¯ããŠããããžã§ã¯ããã©ã«ããŒã§ä»¥åã«ä¿åããã©ã€ãã©ãªãèŠã€ããŠè¿œå ããŸãã å€éšã©ã€ãã©ãªãè¿œå ãããšãèšå®ãŠã£ã³ããŠã¯æ¬¡ã®åœ¢åŒã«ãªããŸãã
以äžã¯ãµãŒãã¹ã®ãœãŒã¹ã³ãŒãã§ããonCreateã¡ãœãããèŠããšãããããã«ãSMACKã©ã€ââãã©ãªã䜿çšããŠXMPPãããã³ã«ãä»ãã察話ã®äž»ãªäœæ¥ãè¡ãããå¥ã®ã¹ããªãŒã ãäœæãããŸãã åä¿¡ããã¡ãã»ãŒãžãããã³ãµãŒãã¹ã®ä»ã®ã¹ããŒã¿ã¹ã¯ããããŒããã£ã¹ãã®æå³ãéä¿¡ããããšã«ããéä¿¡ãããŸãã
package ru.blagin.xmppsmsgate; import java.util.Collection; import org.jivesoftware.smack.Chat; import org.jivesoftware.smack.ChatManager; import org.jivesoftware.smack.ConnectionConfiguration; import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.SASLAuthentication; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.PacketFilter; import org.jivesoftware.smack.filter.PacketTypeFilter; import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Packet; import org.jivesoftware.smack.packet.Presence; import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.util.Log; public class XMPPSMSGateService extends Service { private ConnectionConfiguration connConfig; private XMPPConnection connection; Thread th = null; Intent in = new Intent("SMSGate_Service"); @Override public IBinder onBind(Intent arg0){return null;} @Override public int onStartCommand(Intent intent, int flags, int startId){return Service.START_STICKY;} @Override public void onCreate() { super.onCreate(); th= new Thread() { public void run() { in.putExtra("Message","The service is started"); sendBroadcast(in); connConfig = new ConnectionConfiguration(/*domen*/,5222,/*server*/); SASLAuthentication.supportSASLMechanism("PLAIN"); connConfig.setCompressionEnabled(false); connConfig.setSASLAuthenticationEnabled(true); connection = new XMPPConnection(connConfig); try { in.putExtra("Message","Connect to the XMPP server"); sendBroadcast(in); connection.connect(); in.putExtra("Message","Login into the XMPP server"); sendBroadcast(in); connection.login(/*login*/,/*password*/); if(connection.isConnected()) { in.putExtra("Message","SMS Gate online."); sendBroadcast(in); }else { in.putExtra("Message","SMS Gate offline."); sendBroadcast(in); } Presence presence = new Presence(Presence.Type.available); presence.setStatus("SMS Gate"); presence.setPriority(30); connection.sendPacket(presence); PacketFilter filter = new AndFilter(new PacketTypeFilter(Message.class)); PacketListener myListener = new PacketListener() { public void processPacket(Packet packet) { if(packet instanceof Message) { Message message = (Message) packet; String messageBody = message.getBody(); String JID = message.getFrom(); if(messageBody == null) { messageBody = ""; Collection<Message.Body> bodies = message.getBodies(); for(Message.Body r:bodies){messageBody += r.getMessage();} } if(messageBody.equals("ping")){sendMessage(JID,"pong");} in.putExtra("Message",messageBody); sendBroadcast(in); } } }; connection.addPacketListener(myListener, filter); while(connection.isConnected()) { try{Thread.sleep(1000);}catch(Exception e){Log.e(this.getClass().getName(),e.getMessage());} } }catch(Exception e) { Log.e(this.getClass().getName(),e.getMessage()); in.putExtra("Message","ERROR: "+e.getMessage()); sendBroadcast(in); } } public void sendMessage(String to, String message) { if(!message.equals("")) { ChatManager chatmanager = connection.getChatManager(); Chat newChat = chatmanager.createChat(to, null); try{newChat.sendMessage(message);} catch(Exception e) {Log.e(this.getClass().getName(),e.getMessage());} } } }; th.start(); } @Override public void onDestroy() { if(connection.isConnected()){connection.disconnect();th = null;} in.putExtra("Message","The service is stopped"); sendBroadcast(in); } }
ãµãŒãã¹ããåä¿¡ãããããŒããã£ã¹ãã€ã³ãã³ã·ã§ã³ãåŠçããã«ã¯ããããŒããã£ã¹ãã€ã³ãã³ã·ã§ã³ã®å¥ã®ã¬ã·ãŒããŒãç»é²ããå¿ èŠããããŸãããã®ããã«ãã¢ããªã±ãŒã·ã§ã³ã®ã¡ã€ã³ã¯ã©ã¹ã®onCreateã¡ãœããã«æ¬¡ã®ã³ãŒããè¿œå ããŸãã
IntentFilter filter = new IntentFilter(); filter.addAction("SMSGate_Service"); service = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if(intent.getAction().equals("SMSGate_Service")) { String message = intent.getStringExtra("Message"); tv.append(message+"\n"); int i = message.indexOf("@"); if(i != -1) { String phone = message.substring(0, i); if(phone.length() != 0) { String text = message.substring(i+1,message.length()); tv.append("Sending SMS...\n"); SendSMS(phone,text); }else{/*phone: 0*/} }else{/*not sms message*/} } } }; registerReceiver(service, filter);
äžèšã®ã³ãŒããããããããã«ãSMSãéä¿¡ããã«ã¯ãã¿ã€ããphone_number @ message_textã®ã¡ãã»ãŒãžãåŠçãããŸãã次ã«äŸã瀺ããŸãã
5556@
ãµãŒãã¹ãéå§ããã«ã¯ãã¢ããªã±ãŒã·ã§ã³ã®ã¡ã€ã³ã¯ã©ã¹ã§ã onCreateã¡ãœããã«æ¬¡ã®è¡ãè¿œå ããŸã ã
startService(new Intent(this,XMPPSMSGateService.class));
ãµãŒãã¹ãåæ¢ããã«ã¯ã onDestroyã¡ãœããã®ã¡ã€ã³ã¢ããªã±ãŒã·ã§ã³ã¯ã©ã¹ã§æ¬¡ã®è¡ãè¿œå ããŸãã
stopService(new Intent(this,XMPPSMSGateService.class));
ãšãã¥ã¬ãŒã¿ã§ã¢ããªã±ãŒã·ã§ã³ãå®è¡ããIMã¯ã©ã€ã¢ã³ããä»ããŠç¹å®ã®ã¿ã€ãã®ã¡ãã»ãŒãžãéä¿¡ããŠã¿ãŸãããã çµæã¯ç»åã«ç€ºãããŠããŸãïŒ
ãããã«
ãã®èšäºã¯å ¥éèšäºã§ãããç§èªèº«ã®åå¿è ããã°ã©ããŒã察象ãšããŠããŸãã äœæãããã¢ããªã±ãŒã·ã§ã³ã«ã¯ãå€ãã®æ¬ ç¹ãšå¶éããããŸããããšãã°ãSMSã¡ãã»ãŒãžã®éä¿¡ã¯ãã¡ã€ã³ã¢ããªã±ãŒã·ã§ã³ãŠã£ã³ããŠãã¢ã¯ãã£ããªå Žåã«ã®ã¿å®è¡ãããŸãã ã€ã³ã¿ãŒãããã¢ã¯ã»ã¹ãWI-FIã®ã¿ãä»ããŠè¡ãããŠããå Žåãã€ã³ã¿ãŒãããã¢ã¯ã»ã¹ã®ãã§ãã¯ã¯è¡ãããŸãããããã€ã¹ãã¹ãªãŒãã¢ãŒãã«ãªããšãããããªãŒãç¯çŽããããã«WI-FIããªãã«ãªããŸãã ãã®åé¡ã¯ã Wi-Fi Keep Aliveã¢ããªã±ãŒã·ã§ã³ã䜿çšããããã¢ããªã±ãŒã·ã§ã³ã«èªåã§ãã®æ©èœãè¿œå ããããšã§åé¿ã§ããŸãã éåä¿¡ãããã¡ãã»ãŒãžã®ãã°ã¯ãããŸããã
ãã®ã¢ããªã±ãŒã·ã§ã³ã®é©çšç¯å²ã¯ã泚æéç¥ã®åä¿¡ãããããŸããŸãªããŒã¿ãåŠçããããã®æ¬æ ŒçãªSMSã²ãŒããŠã§ã€ã®äœæãŸã§ãéåžžã«åºç¯å²ã§ãã
ã¢ããªã±ãŒã·ã§ã³ã®ãœãŒã¹ã³ãŒãã
䜿çšãããæç®ã®ãªã¹ã
- Alexey GoloshchapovãGoogle Androidã ã¢ãã€ã«ããã€ã¹çšã®ããã°ã©ãã³ã°ã2012
- Alexey GoloshchapovãGoogle Androidã ã·ã¹ãã ã³ã³ããŒãã³ããšãããã¯ãŒã¯éä¿¡ã2012
- Smack API ïŒ esin ïŒ ã䜿çšããJavaã®XMPPããã ã