當前位置: 首頁>>代碼示例>>Java>>正文


Java Telephony類代碼示例

本文整理匯總了Java中android.provider.Telephony的典型用法代碼示例。如果您正苦於以下問題:Java Telephony類的具體用法?Java Telephony怎麽用?Java Telephony使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Telephony類屬於android.provider包,在下文中一共展示了Telephony類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkReadSms

import android.provider.Telephony; //導入依賴的package包/類
/**
 * read sms, {@link Manifest.permission#READ_SMS}
 * in MEIZU 5.0~6.0, just according normal phone request
 * in XIAOMI 6.0~, need force judge
 * in XIAOMI 5.0~6.0, not test!!!
 *
 * @param activity
 * @return true if success
 * @throws Exception
 */
private static boolean checkReadSms(Context activity) throws Exception {
    Cursor cursor = activity.getContentResolver().query(Uri.parse("content://sms/"), null, null,
            null, null);
    if (cursor != null) {
        if (ManufacturerSupportUtil.isForceManufacturer()) {
            if (isNumberIndexInfoIsNull(cursor, cursor.getColumnIndex(Telephony.Sms.DATE))) {
                cursor.close();
                return false;
            }
        }
        cursor.close();
        return true;
    } else {
        return false;
    }
}
 
開發者ID:paozhuanyinyu,項目名稱:XPermission,代碼行數:27,代碼來源:PermissionsChecker.java

示例2: getSmsCodeFromReceiver

import android.provider.Telephony; //導入依賴的package包/類
/**
 * 包訪問級別:提高性能
 * 從接收者中得到短信驗證碼
 *
 * @param intent
 */
void getSmsCodeFromReceiver(Intent intent) {
    SmsMessage[] messages = null;
    if (Build.VERSION.SDK_INT >= 19) {
        messages = android.provider.Telephony.Sms.Intents.getMessagesFromIntent(intent);
        if (messages == null) return;
    } else {
        messages = getSmsUnder19(intent);
        if (messages == null) return;
    }

    if (messages.length > 0) {
        for (int i = 0; i < messages.length; i++) {
            SmsMessage sms = messages[i];
            String smsSender = sms.getOriginatingAddress();
            String smsBody = sms.getMessageBody();
            if (checkSmsSender(smsSender) && checkSmsBody(smsBody)) {
                String smsCode = parseSmsBody(smsBody);
                sendMsg2Register(OBSERVER_SMS_CODE_MSG, smsCode);
                break;
            }
        }
    }
}
 
開發者ID:xiong-it,項目名稱:AutoInputAuthCode,代碼行數:30,代碼來源:ReadSmsService.java

示例3: getSmsCodeFromObserver

import android.provider.Telephony; //導入依賴的package包/類
/**
 * 包訪問級別:提高性能
 * 從內容觀察者得到短信驗證碼
 *
 * @param cursor
 */
void getSmsCodeFromObserver(Cursor cursor) {
    if (cursor == null) return;

    while (cursor.moveToNext()) {
        String address = cursor.getString(cursor.getColumnIndex(Telephony.Sms.ADDRESS));
        String smsBody = cursor.getString(cursor.getColumnIndex(Telephony.Sms.BODY));
        if (checkSmsSender(address) && checkSmsBody(smsBody)) {
            String smsCode = parseSmsBody(smsBody);
            sendMsg2Register(RECEIVER_SMS_CODE_MSG, smsCode);
            break;
        }
    }

    closeCursor(cursor);
}
 
開發者ID:xiong-it,項目名稱:AutoInputAuthCode,代碼行數:22,代碼來源:ReadSmsService.java

示例4: isRelevant

import android.provider.Telephony; //導入依賴的package包/類
private boolean isRelevant(Context context, Intent intent) {
  if (!ApplicationMigrationService.isDatabaseImported(context)) {
    return false;
  }

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT &&
      Telephony.Sms.Intents.WAP_PUSH_RECEIVED_ACTION.equals(intent.getAction()) &&
      Util.isDefaultSmsProvider(context))
  {
    return false;
  }

  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT &&
      TextSecurePreferences.isInterceptAllMmsEnabled(context))
  {
    return true;
  }

  return false;
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:21,代碼來源:MmsListener.java

示例5: onReceive

import android.provider.Telephony; //導入依賴的package包/類
@Override
  public void onReceive(Context context, Intent intent) {
  Log.w(TAG, "Got MMS broadcast..." + intent.getAction());

  if ((Telephony.Sms.Intents.WAP_PUSH_DELIVER_ACTION.equals(intent.getAction())  &&
      Util.isDefaultSmsProvider(context))                                        ||
      (Telephony.Sms.Intents.WAP_PUSH_RECEIVED_ACTION.equals(intent.getAction()) &&
       isRelevant(context, intent)))
  {
    Log.w(TAG, "Relevant!");
    int subscriptionId = intent.getExtras().getInt("subscription", -1);

    ApplicationContext.getInstance(context)
                      .getJobManager()
                      .add(new MmsReceiveJob(context, intent.getByteArrayExtra("data"), subscriptionId));

    abortBroadcast();
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:20,代碼來源:MmsListener.java

示例6: checkReadSms

import android.provider.Telephony; //導入依賴的package包/類
/**
 * read sms, {@link android.Manifest.permission#READ_SMS}
 * in MEIZU 5.0~6.0, just according normal phone request
 * in XIAOMI 6.0~, need force judge
 * in XIAOMI 5.0~6.0, not test!!!
 *
 * @param activity
 * @return true if success
 * @throws Exception
 */
private static boolean checkReadSms(Activity activity) throws Exception {
    Cursor cursor = activity.getContentResolver().query(Uri.parse("content://sms/"), null, null,
            null, null);
    if (cursor != null) {
        if (ManufacturerSupportUtil.isForceManufacturer()) {
            if (isNumberIndexInfoIsNull(cursor, cursor.getColumnIndex(Telephony.Sms.DATE))) {
                cursor.close();
                return false;
            }
        }
        cursor.close();
        return true;
    } else {
        return false;
    }
}
 
開發者ID:jokermonn,項目名稱:permissions4m,代碼行數:27,代碼來源:PermissionsChecker.java

示例7: insertSmsLog

import android.provider.Telephony; //導入依賴的package包/類
/**
 * 新增短信記錄代理信息
 **/
private void insertSmsLog() {
    Cursor cursor = mContext.getContentResolver().query(
            Uri.parse(PhoneContactUtils.SMS_URI_ALL), new String[]{Telephony.Sms._ID, "read"}, null, null, "date DESC");
    if (cursor == null || cursor.getCount() <= 0)
        return;
    while (cursor.moveToNext()) {
        long id = cursor.getLong(cursor.getColumnIndex(Telephony.Sms._ID));
        SmsProxy msg = findSmsById(id);
        if (msg == null) {
            msg = new SmsProxy();
            msg.setId(id);
            mSmsDao.insert(msg);
        }
    }
    cursor.close();
}
 
開發者ID:LingjuAI,項目名稱:AssistantBySDK,代碼行數:20,代碼來源:CallAndSmsDao.java

示例8: onReceive

import android.provider.Telephony; //導入依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals(Telephony.Sms.Intents.SMS_RECEIVED_ACTION)) {
        String smsSender = "";
        String smsBody = "";
        for (SmsMessage smsMessage : Telephony.Sms.Intents.getMessagesFromIntent(intent)) {
            smsBody += smsMessage.getMessageBody();
        }

        if (smsBody.startsWith(SmsHelper.SMS_CONDITION)) {
            Log.d(TAG, "Sms with condition detected");
            Toast.makeText(context, "BroadcastReceiver caught conditional SMS: " + smsBody, Toast.LENGTH_LONG).show();
        }
        Log.d(TAG, "SMS detected: From " + smsSender + " With text " + smsBody);
    }
}
 
開發者ID:JoaquimLey,項目名稱:sms-parsing,代碼行數:17,代碼來源:SmsBroadcastReceiver.java

示例9: askForDefaultAppChange

import android.provider.Telephony; //導入依賴的package包/類
@TargetApi(19)
public static void askForDefaultAppChange(Fragment fragment, int requestCode) {
    if (!isAvailable()) return;
    Context context = fragment.getContext().getApplicationContext();
    String packageName;
    // current app package is already set as default
    if (isDefault(context)) {
        // get previously saved app package as default
        packageName = Settings.getStringValue(context, Settings.DEFAULT_SMS_APP_NATIVE_PACKAGE);
    } else {
        // get blacklist app package as default
        packageName = context.getPackageName();
        // save current default sms app package to the settings
        String nativePackage = Telephony.Sms.getDefaultSmsPackage(context);
        if (nativePackage != null) {
            Settings.setStringValue(context, Settings.DEFAULT_SMS_APP_NATIVE_PACKAGE, nativePackage);
        }
    }
    // start sms app change dialog
    askForDefaultAppChange(fragment, packageName, requestCode);
}
 
開發者ID:kaliturin,項目名稱:BlackList,代碼行數:22,代碼來源:DefaultSMSAppHelper.java

示例10: onReceive

import android.provider.Telephony; //導入依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    if(intent.getAction().equals(Telephony.Sms.Intents.SMS_RECEIVED_ACTION)) {
        MBApp application = MBApp.getApp();

        Intent charChangedIntent = new Intent(application, IPCService.class);
        charChangedIntent.putExtra(IPCConstants.INTENT_TYPE, EventCategories.IPC_BLE_NOTIFICATION_CHARACTERISTIC_CHANGED);
        charChangedIntent.putExtra(IPCConstants.INTENT_CHARACTERISTIC_MESSAGE, Utils.makeMicroBitValue
                (EventCategories.SAMSUNG_DEVICE_INFO_ID, EventSubCodes.SAMSUNG_INCOMING_SMS));
        application.startService(charChangedIntent);
    }
}
 
開發者ID:Samsung,項目名稱:microbit,代碼行數:13,代碼來源:IncomingSMSPresenter.java

示例11: initializeDefaultPreference

import android.provider.Telephony; //導入依賴的package包/類
private void initializeDefaultPreference() {
  if (VERSION.SDK_INT < VERSION_CODES.KITKAT) return;

  Preference defaultPreference = findPreference(KITKAT_DEFAULT_PREF);
  if (Util.isDefaultSmsProvider(getActivity())) {
    defaultPreference.setIntent(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
    defaultPreference.setTitle(getString(R.string.ApplicationPreferencesActivity_sms_enabled));
    defaultPreference.setSummary(getString(R.string.ApplicationPreferencesActivity_touch_to_change_your_default_sms_app));
  } else {
    Intent intent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
    intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, getActivity().getPackageName());
    defaultPreference.setIntent(intent);
    defaultPreference.setTitle(getString(R.string.ApplicationPreferencesActivity_sms_disabled));
    defaultPreference.setSummary(getString(R.string.ApplicationPreferencesActivity_touch_to_make_signal_your_default_sms_app));
  }
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:17,代碼來源:SmsMmsPreferenceFragment.java

示例12: getConversations

import android.provider.Telephony; //導入依賴的package包/類
@GET
@Path("conversations")
@Secure
public Response getConversations() {
    List<Conversation> conversations = new ArrayList<>();
    Cursor cur = deskDroidService.getApplication().getContentResolver()
            .query(Telephony.Sms.Conversations.CONTENT_URI, null, null, null, null);
    while (cur.moveToNext()) {
        conversations.add(buildConversation(cur));
    }
    cur.close();

    Collections.sort(conversations, new ConversationComparator());

    return Response.ok(new GenericEntity<List<Conversation>>(conversations) {
    }).build();
}
 
開發者ID:PacktPublishing,項目名稱:Java-9-Programming-Blueprints,代碼行數:18,代碼來源:DeskDroidResource.java

示例13: getIntent

import android.provider.Telephony; //導入依賴的package包/類
protected Intent getIntent(Context context) {
       Intent sendIntent;

       if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { //At least KitKat
           String defaultSmsPackageName = Telephony.Sms.getDefaultSmsPackage(context); //Need to change the build to API 19

           sendIntent = new Intent(Intent.ACTION_SEND);

           if (defaultSmsPackageName != null) {
               sendIntent.setPackage(defaultSmsPackageName);
           }
       }
       else {
           sendIntent = new Intent(Intent.ACTION_VIEW);
       }

       sendIntent.setType(getMimeType());
	return sendIntent;
}
 
開發者ID:dylanmaryk,項目名稱:InsanityRadio-Android,代碼行數:20,代碼來源:SmsShareHandler.java

示例14: countMsgsFrom

import android.provider.Telephony; //導入依賴的package包/類
private Cursor countMsgsFrom(String phoneNumber) {

        String[] select = {
                Telephony.Sms._ID,
                Telephony.Sms.ADDRESS,
                Telephony.Sms.BODY,
        };
        String whereClause =
                Telephony.Sms.ADDRESS +" = '"+phoneNumber+"'";
        Uri quri = Uri.parse("content://sms/inbox");
        return getContentResolver().query(quri,
                select, // Columns to select
                whereClause, // Clause to filter results
                null, // Arguments for the whereClause
                null);
    }
 
開發者ID:PacktPublishing,項目名稱:Asynchronous-Android-Programming,代碼行數:17,代碼來源:CountMsgsIntentService.java

示例15: isDefaultApp

import android.provider.Telephony; //導入依賴的package包/類
static boolean isDefaultApp(final Context context) {
    // there is no default sms app before android 4.4
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        return true;
    }

    try {
        // check if this is the default sms app.
        // If the device doesn't support Telephony.Sms (i.e. tablet) getDefaultSmsPackage() will
        // be null.
        final String smsPackage = Telephony.Sms.getDefaultSmsPackage(context);
        return smsPackage == null || smsPackage.equals(BuildConfig.APPLICATION_ID);
    } catch (SecurityException e) {
        // some samsung devices/tablets want permission GET_TASKS o.O
        Log.e(TAG, "failed to query default SMS app", e);
        return true;
    }
}
 
開發者ID:andrewxu10,項目名稱:Upkeep,代碼行數:19,代碼來源:SMSdroid.java


注:本文中的android.provider.Telephony類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。