mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 11:38:51 +01:00
Implemented SMSSendService
This commit is contained in:
@@ -1,12 +1,49 @@
|
||||
package com.moez.QKSMS.service;
|
||||
|
||||
import android.app.Service;
|
||||
import android.app.IntentService;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import com.moez.QKSMS.mmssms.Message;
|
||||
import com.moez.QKSMS.mmssms.Transaction;
|
||||
import com.moez.QKSMS.transaction.NotificationManager;
|
||||
import com.moez.QKSMS.transaction.SmsHelper;
|
||||
|
||||
import static com.moez.QKSMS.data.Conversation.getRecipients;
|
||||
|
||||
public class HeadlessSmsSendService extends IntentService {
|
||||
private static final String TAG = "HeadlessSmsSendService";
|
||||
|
||||
public HeadlessSmsSendService() {
|
||||
super(TAG);
|
||||
}
|
||||
|
||||
public class HeadlessSmsSendService extends Service {
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
protected void onHandleIntent(Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (!TelephonyManager.ACTION_RESPOND_VIA_MESSAGE.equals(action)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Bundle extras = intent.getExtras();
|
||||
if (extras != null) {
|
||||
String body = extras.getString(Intent.EXTRA_TEXT);
|
||||
Uri intentUri = intent.getData();
|
||||
String recipients = getRecipients(intentUri);
|
||||
|
||||
if (!TextUtils.isEmpty(recipients) && !TextUtils.isEmpty(body)) {
|
||||
String[] destinations = TextUtils.split(recipients, ";");
|
||||
|
||||
Transaction sendTransaction = new Transaction(this, SmsHelper.getSendSettings(this));
|
||||
|
||||
Message message = new Message(body, destinations);
|
||||
message.setType(Message.TYPE_SMSMMS);
|
||||
|
||||
sendTransaction.sendNewMessage(message, Transaction.NO_THREAD_ID);
|
||||
NotificationManager.update(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,6 +3,6 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.2.0-alpha3'
|
||||
classpath 'com.android.tools.build:gradle:2.1.2'
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user