当前位置: 首页>>代码示例>>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;未经允许,请勿转载。