use of dev.sagar.smsblocker.tech.beans.SMS in project SMSBlocker by sagarpawardev.
the class LocalSMSSentReceiver method onReceive.
/**
* This method is called by Android when SMS is Received
* @param context Context
* @param intent SMSReceived Intent
*/
@Override
public void onReceive(Context context, Intent intent) {
final String methodName = "onReceive()";
log.justEntered(methodName);
String action = intent.getAction();
Bundle basket = intent.getExtras();
String jsonSMS = basket.getString(KEY_SMS);
SMS sms = gson.fromJson(jsonSMS, SMS.class);
String msg = null;
switch(action) {
case SMSSentReceiver.KEY_SMS_SENT:
sms.setType(SMS.TYPE_SENT);
msg = context.getString(R.string.txt_sms_sent);
callback.onSMSSent(sms);
break;
case SMSSentReceiver.KEY_GENERIC_FAILURE:
sms.setType(SMS.TYPE_FAILED);
msg = context.getString(R.string.err_generic_failure);
callback.onSMSSentFailure(sms);
break;
case SMSSentReceiver.KEY_NO_SERVICE:
sms.setType(SMS.TYPE_FAILED);
msg = context.getString(R.string.err_no_service);
callback.onSMSSentFailure(sms);
break;
case SMSSentReceiver.KEY_RADIO_OFF:
msg = context.getString(R.string.err_radio_off);
sms.setType(SMS.TYPE_FAILED);
callback.onSMSSentFailure(sms);
break;
case SMSSentReceiver.KEY_NULL_PDU_FLAG:
msg = context.getString(R.string.err_null_pdu);
sms.setType(SMS.TYPE_FAILED);
callback.onSMSSentFailure(sms);
break;
}
if (msg != null) {
log.info(methodName, "Toasting text: " + msg);
Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
}
log.returning(methodName);
}
use of dev.sagar.smsblocker.tech.beans.SMS in project SMSBlocker by sagarpawardev.
the class SMSDeliveredReceiver method resultOk.
private void resultOk(Context context, Intent intent) {
final String methodName = "resultOk(Context, Intent)";
log.justEntered(methodName);
Bundle basket = intent.getExtras();
SMS sms = (SMS) basket.getSerializable(KEY_SMS);
log.info(methodName, "Broadcasting Locally");
broadcastLocalSMS(context, sms, KEY_SMS_DELIVERED);
}
use of dev.sagar.smsblocker.tech.beans.SMS in project SMSBlocker by sagarpawardev.
the class SMSSentReceiver method resultFailure.
private void resultFailure(Context context, Intent intent, String resultCode) {
final String methodName = "resultOk(Context, Intent)";
log.justEntered(methodName);
try {
Bundle basket = intent.getExtras();
log.debug(methodName, "Sgr Receiving key: " + KEY_SMS);
String strSMS = basket.getString(KEY_SMS);
SMS sms = gson.fromJson(strSMS, SMS.class);
String id = sms.getId();
String selection = _id + " = ?";
String[] selectionArgs = { id };
ContentValues values = new ContentValues();
values.put(type, SMS.TYPE_FAILED);
int updateCount = context.getContentResolver().update(SMS_URI, values, selection, selectionArgs);
log.info(methodName, "Update Count: " + updateCount);
log.info(methodName, "Broadcasting Locally");
broadcastLocalSMS(context, sms, resultCode);
} catch (NullPointerException e) {
e.printStackTrace();
}
log.returning(methodName);
}
use of dev.sagar.smsblocker.tech.beans.SMS in project SMSBlocker by sagarpawardev.
the class LocalSMSDeliveredReceiver method onReceive.
/**
* This method is called by Android when SMS is Received
* @param context
* @param intent
*/
@Override
public void onReceive(Context context, Intent intent) {
final String methodName = "onReceive()";
log.justEntered(methodName);
Bundle basket = intent.getExtras();
String jsonSMS = basket.getString(KEY_SMS);
SMS sms = gson.fromJson(jsonSMS, SMS.class);
String action = intent.getAction();
String msg = null;
switch(action) {
case SMSDeliveredReceiver.KEY_SMS_DELIVERED:
msg = context.getString(R.string.txt_delivered);
log.info(methodName, "Calling Callback");
callback.onSMSDelivered(sms);
break;
case SMSDeliveredReceiver.KEY_DELIVERY_CANCELLED:
msg = context.getString(R.string.err_delivery_cancelled);
break;
}
if (msg != null) {
log.info(methodName, "Toasting text: " + msg);
Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
}
log.returning(methodName);
}
use of dev.sagar.smsblocker.tech.beans.SMS in project SMSBlocker by sagarpawardev.
the class LocalSMSReceivedReceiver method onReceive.
/**
* This method is called by Android when SMS is Received
* @param context
* @param intent
*/
@Override
public void onReceive(Context context, Intent intent) {
final String methodName = "onReceive()";
log.justEntered(methodName);
// Receive SMS
if (intent.getAction().equals(EVENT_RECEIVED)) {
Bundle bundle = intent.getExtras();
String jsonSMS = bundle.getString(KEY_SMS);
SMS sms = gson.fromJson(jsonSMS, SMS.class);
log.info(methodName, "Calling Callback");
callback.onSMSReceived(sms);
}
log.returning(methodName);
}
Aggregations