android.content.Intent#toString ( )源码实例Demo

下面列出了android.content.Intent#toString ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: BlackList   文件: SMSProcessService.java
private Map<String, String> extractMessageData(@Nullable Intent intent) throws IllegalArgumentException {
    Map<String, String> data = new HashMap<>();
    if (intent != null) {
        String[] keys = intent.getStringArrayExtra(KEYS);
        String[] values = intent.getStringArrayExtra(VALUES);
        if (keys != null && values != null && keys.length == values.length) {
            for (int i = 0; i < keys.length; i++) {
                data.put(keys[i], values[i]);
            }
        }
    }

    if (data.isEmpty()) {
        String intentString = (intent == null ? "null" : intent.toString());
        throw new IllegalArgumentException("Message intent data is illegal: " + intentString);
    }

    return data;
}
 
源代码2 项目: AndroidAnimationExercise   文件: OPPOHomeBader.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public void executeBadge(Context context, ComponentName componentName, int badgeCount) throws ShortcutBadgeException {
    if (badgeCount == 0) {
        badgeCount = -1;
    }
    Intent intent = new Intent(INTENT_ACTION);
    intent.putExtra(INTENT_EXTRA_PACKAGENAME, componentName.getPackageName());
    intent.putExtra(INTENT_EXTRA_BADGE_COUNT, badgeCount);
    intent.putExtra(INTENT_EXTRA_BADGE_UPGRADENUMBER, badgeCount);
    if (BroadcastHelper.canResolveBroadcast(context, intent)) {
        context.sendBroadcast(intent);
    } else {
        int version = getSupportVersion();
        if (version == 6) {
            try {
                Bundle extras = new Bundle();
                extras.putInt(INTENT_EXTRA_BADGEUPGRADE_COUNT, badgeCount);
                context.getContentResolver().call(Uri.parse(PROVIDER_CONTENT_URI), "setAppBadgeCount", null, extras);
            } catch (Throwable th) {
                throw new ShortcutBadgeException("unable to resolve intent: " + intent.toString());
            }
        }
    }
}
 
@Override
public void executeBadge(Context context, ComponentName componentName, int badgeCount) throws ShortcutBadgeException {
    try {
        Class miuiNotificationClass = Class.forName("android.app.MiuiNotification");
        Object miuiNotification = miuiNotificationClass.newInstance();
        Field field = miuiNotification.getClass().getDeclaredField("messageCount");
        field.setAccessible(true);
        field.set(miuiNotification, String.valueOf(badgeCount == 0 ? "" : badgeCount));
    } catch (Exception e) {
        Intent localIntent = new Intent(
                INTENT_ACTION);
        localIntent.putExtra(EXTRA_UPDATE_APP_COMPONENT_NAME, componentName.getPackageName() + "/" + componentName.getClassName());
        localIntent.putExtra(EXTRA_UPDATE_APP_MSG_TEXT, String.valueOf(badgeCount == 0 ? "" : badgeCount));
        if (BroadcastHelper.canResolveBroadcast(context, localIntent)) {
            context.sendBroadcast(localIntent);
        } else {
            throw new ShortcutBadgeException("unable to resolve intent: " + localIntent.toString());
        }
    }
}
 
源代码4 项目: AndroidBase   文件: NewHtcHomeBadger.java
@Override
public void executeBadge(Context context, ComponentName componentName, int badgeCount) throws ShortcutBadgeException {

    Intent intent1 = new Intent(INTENT_SET_NOTIFICATION);
    intent1.putExtra(EXTRA_COMPONENT, componentName.flattenToShortString());
    intent1.putExtra(EXTRA_COUNT, badgeCount);

    Intent intent = new Intent(INTENT_UPDATE_SHORTCUT);
    intent.putExtra(PACKAGENAME, componentName.getPackageName());
    intent.putExtra(COUNT, badgeCount);

    if(BroadcastHelper.canResolveBroadcast(context, intent1) || BroadcastHelper.canResolveBroadcast(context, intent)) {
        context.sendBroadcast(intent1);
        context.sendBroadcast(intent);
    } else {
        throw new ShortcutBadgeException("unable to resolve intent: " + intent.toString());
    }
}
 
源代码5 项目: AndroidBase   文件: OPPOHomeBader.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public void executeBadge(Context context, ComponentName componentName, int badgeCount) throws ShortcutBadgeException {
    if (badgeCount == 0) {
        badgeCount = -1;
    }
    Intent intent = new Intent(INTENT_ACTION);
    intent.putExtra(INTENT_EXTRA_PACKAGENAME, componentName.getPackageName());
    intent.putExtra(INTENT_EXTRA_BADGE_COUNT, badgeCount);
    intent.putExtra(INTENT_EXTRA_BADGE_UPGRADENUMBER, badgeCount);
    if (BroadcastHelper.canResolveBroadcast(context, intent)) {
        context.sendBroadcast(intent);
    } else {
        int version = getSupportVersion();
        if (version == 6) {
            try {
                Bundle extras = new Bundle();
                extras.putInt(INTENT_EXTRA_BADGEUPGRADE_COUNT, badgeCount);
                context.getContentResolver().call(Uri.parse(PROVIDER_CONTENT_URI), "setAppBadgeCount", null, extras);
            } catch (Throwable th) {
                throw new ShortcutBadgeException("unable to resolve intent: " + intent.toString());
            }
        }
    }
}
 
源代码6 项目: AndroidBase   文件: XiaomiHomeBadger.java
@Override
public void executeBadge(Context context, ComponentName componentName, int badgeCount) throws ShortcutBadgeException {
    try {
        Class miuiNotificationClass = Class.forName("android.app.MiuiNotification");
        Object miuiNotification = miuiNotificationClass.newInstance();
        Field field = miuiNotification.getClass().getDeclaredField("messageCount");
        field.setAccessible(true);
        field.set(miuiNotification, String.valueOf(badgeCount == 0 ? "" : badgeCount));
    } catch (Exception e) {
        Intent localIntent = new Intent(
                INTENT_ACTION);
        localIntent.putExtra(EXTRA_UPDATE_APP_COMPONENT_NAME, componentName.getPackageName() + "/" + componentName.getClassName());
        localIntent.putExtra(EXTRA_UPDATE_APP_MSG_TEXT, String.valueOf(badgeCount == 0 ? "" : badgeCount));
        if (BroadcastHelper.canResolveBroadcast(context, localIntent)) {
            context.sendBroadcast(localIntent);
        } else {
            throw new ShortcutBadgeException("unable to resolve intent: " + localIntent.toString());
        }
    }
}
 
源代码7 项目: AndroidBase   文件: AdwHomeBadger.java
@Override
public void executeBadge(Context context, ComponentName componentName, int badgeCount) throws ShortcutBadgeException {

    Intent intent = new Intent(INTENT_UPDATE_COUNTER);
    intent.putExtra(PACKAGENAME, componentName.getPackageName());
    intent.putExtra(CLASSNAME, componentName.getClassName());
    intent.putExtra(COUNT, badgeCount);
    if (BroadcastHelper.canResolveBroadcast(context, intent)) {
        context.sendBroadcast(intent);
    } else {
        throw new ShortcutBadgeException("unable to resolve intent: " + intent.toString());
    }
}
 
源代码8 项目: GotoSleep   文件: MainActivity.java
private void sendToPlayStore(){
    final Uri uri = Uri.parse("market://details?id=" + getApplicationContext().getPackageName());
    final Intent rateAppIntent = new Intent(Intent.ACTION_VIEW, uri);

    if (getPackageManager().queryIntentActivities(rateAppIntent, 0).size() > 0)
    {
        startActivity(rateAppIntent);
        rateAppIntent.toString();
    }
    else
    {
        /* handle your error case: the device has no way to handle market urls */
    }
}
 
源代码9 项目: BadgeForAppIcon   文件: SamsungModelImpl.java
@Override
public Notification setIconBadgeNum(@NonNull Application context, Notification notification, int count) throws Exception {
    Intent intent = new Intent("android.intent.action.BADGE_COUNT_UPDATE");
    intent.putExtra("badge_count", count);
    intent.putExtra("badge_count_package_name", context.getPackageName());
    intent.putExtra("badge_count_class_name", Utils.getInstance().getLaunchIntentForPackage(context));

    if (Utils.getInstance().canResolveBroadcast(context, intent)) {
        context.sendBroadcast(intent);
    } else {
        throw new Exception(UNABLE_TO_RESOLVE_INTENT_ERROR_ + intent.toString());
    }
    return notification;
}
 
源代码10 项目: AndroidAnimationExercise   文件: ApexHomeBadger.java
@Override
public void executeBadge(Context context, ComponentName componentName, int badgeCount) throws ShortcutBadgeException {

    Intent intent = new Intent(INTENT_UPDATE_COUNTER);
    intent.putExtra(PACKAGENAME, componentName.getPackageName());
    intent.putExtra(COUNT, badgeCount);
    intent.putExtra(CLASS, componentName.getClassName());
    if (BroadcastHelper.canResolveBroadcast(context, intent)) {
        context.sendBroadcast(intent);
    } else {
        throw new ShortcutBadgeException("unable to resolve intent: " + intent.toString());
    }
}
 
源代码11 项目: AndroidAnimationExercise   文件: DefaultBadger.java
@Override
public void executeBadge(Context context, ComponentName componentName, int badgeCount) throws ShortcutBadgeException {
    Intent intent = new Intent(INTENT_ACTION);
    intent.putExtra(INTENT_EXTRA_BADGE_COUNT, badgeCount);
    intent.putExtra(INTENT_EXTRA_PACKAGENAME, componentName.getPackageName());
    intent.putExtra(INTENT_EXTRA_ACTIVITY_NAME, componentName.getClassName());
    if (BroadcastHelper.canResolveBroadcast(context, intent)) {
        context.sendBroadcast(intent);
    } else {
        throw new ShortcutBadgeException("unable to resolve intent: " + intent.toString());
    }
}
 
源代码12 项目: AndroidAnimationExercise   文件: LGHomeBadger.java
@Override
public void executeBadge(Context context, ComponentName componentName, int badgeCount) throws ShortcutBadgeException {
    Intent intent = new Intent(INTENT_ACTION);
    intent.putExtra(INTENT_EXTRA_BADGE_COUNT, badgeCount);
    intent.putExtra(INTENT_EXTRA_PACKAGENAME, componentName.getPackageName());
    intent.putExtra(INTENT_EXTRA_ACTIVITY_NAME, componentName.getClassName());
    if(BroadcastHelper.canResolveBroadcast(context, intent)) {
        context.sendBroadcast(intent);
    } else {
        throw new ShortcutBadgeException("unable to resolve intent: " + intent.toString());
    }
}
 
@Override
public void executeBadge(Context context, ComponentName componentName, int badgeCount) throws ShortcutBadgeException {
    Intent intent = new Intent(INTENT_ACTION);
    intent.putExtra(INTENT_EXTRA_BADGE_COUNT, badgeCount);
    intent.putExtra(INTENT_EXTRA_PACKAGENAME, componentName.getPackageName());
    intent.putExtra(INTENT_EXTRA_ACTIVITY_NAME, componentName.getClassName());
    intent.putExtra("badge_vip_count", 0);
    if (BroadcastHelper.canResolveBroadcast(context, intent)) {
        context.sendBroadcast(intent);
    } else {
        throw new ShortcutBadgeException("unable to resolve intent: " + intent.toString());
    }
}
 
源代码14 项目: AndroidAnimationExercise   文件: AdwHomeBadger.java
@Override
public void executeBadge(Context context, ComponentName componentName, int badgeCount) throws ShortcutBadgeException {

    Intent intent = new Intent(INTENT_UPDATE_COUNTER);
    intent.putExtra(PACKAGENAME, componentName.getPackageName());
    intent.putExtra(CLASSNAME, componentName.getClassName());
    intent.putExtra(COUNT, badgeCount);
    if (BroadcastHelper.canResolveBroadcast(context, intent)) {
        context.sendBroadcast(intent);
    } else {
        throw new ShortcutBadgeException("unable to resolve intent: " + intent.toString());
    }
}
 
源代码15 项目: AndroidBase   文件: AsusHomeLauncher.java
@Override
public void executeBadge(Context context, ComponentName componentName, int badgeCount) throws ShortcutBadgeException {
    Intent intent = new Intent(INTENT_ACTION);
    intent.putExtra(INTENT_EXTRA_BADGE_COUNT, badgeCount);
    intent.putExtra(INTENT_EXTRA_PACKAGENAME, componentName.getPackageName());
    intent.putExtra(INTENT_EXTRA_ACTIVITY_NAME, componentName.getClassName());
    intent.putExtra("badge_vip_count", 0);
    if (BroadcastHelper.canResolveBroadcast(context, intent)) {
        context.sendBroadcast(intent);
    } else {
        throw new ShortcutBadgeException("unable to resolve intent: " + intent.toString());
    }
}
 
源代码16 项目: AndroidBase   文件: DefaultBadger.java
@Override
public void executeBadge(Context context, ComponentName componentName, int badgeCount) throws ShortcutBadgeException {
    Intent intent = new Intent(INTENT_ACTION);
    intent.putExtra(INTENT_EXTRA_BADGE_COUNT, badgeCount);
    intent.putExtra(INTENT_EXTRA_PACKAGENAME, componentName.getPackageName());
    intent.putExtra(INTENT_EXTRA_ACTIVITY_NAME, componentName.getClassName());
    if (BroadcastHelper.canResolveBroadcast(context, intent)) {
        context.sendBroadcast(intent);
    } else {
        throw new ShortcutBadgeException("unable to resolve intent: " + intent.toString());
    }
}
 
源代码17 项目: AndroidBase   文件: VIVOHomeBader.java
@Override
public void executeBadge(Context context, ComponentName componentName, int badgeCount) throws ShortcutBadgeException {
    if (badgeCount == 0) {
        badgeCount = -1;
    }
    Intent intent = new Intent("launcher.action.CHANGE_APPLICATION_NOTIFICATION_NUM");
    intent.putExtra("packageName", componentName.getPackageName());
    intent.putExtra("className", componentName.getClassName());
    intent.putExtra("notificationNum", badgeCount);
    if (BroadcastHelper.canResolveBroadcast(context, intent)) {
        context.sendBroadcast(intent);
    } else {
        throw new ShortcutBadgeException("unable to resolve intent: " + intent.toString());
    }
}
 
源代码18 项目: AndroidBase   文件: LGHomeBadger.java
@Override
public void executeBadge(Context context, ComponentName componentName, int badgeCount) throws ShortcutBadgeException {
    Intent intent = new Intent(INTENT_ACTION);
    intent.putExtra(INTENT_EXTRA_BADGE_COUNT, badgeCount);
    intent.putExtra(INTENT_EXTRA_PACKAGENAME, componentName.getPackageName());
    intent.putExtra(INTENT_EXTRA_ACTIVITY_NAME, componentName.getClassName());
    if(BroadcastHelper.canResolveBroadcast(context, intent)) {
        context.sendBroadcast(intent);
    } else {
        throw new ShortcutBadgeException("unable to resolve intent: " + intent.toString());
    }
}
 
源代码19 项目: android_9.0.0_r45   文件: SafeActivityOptions.java
private String getIntentString(Intent intent) {
    return intent != null ? intent.toString() : "(no intent)";
}
 
源代码20 项目: Yahala-Messenger   文件: ChatActivity.java
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == Activity.RESULT_OK) {
        if (requestCode == 0) {
            Utilities.addMediaToGallery(currentPicturePath);
            processSendingPhoto(currentPicturePath, null);
            currentPicturePath = null;
        } else if (requestCode == 1) {
            if (data == null) {
                return;
            }
            processSendingPhoto(null, data.getData());
        } else if (requestCode == 2) {
            String videoPath = null;
            if (data != null) {
                Uri uri = data.getData();
                boolean fromCamera = false;
                if (uri != null && uri.getScheme() != null) {
                    fromCamera = uri.getScheme().contains("file");
                } else if (uri == null) {
                    fromCamera = true;
                }
                if (fromCamera) {
                    if (uri != null) {
                        videoPath = uri.getPath();
                    } else {
                        videoPath = currentPicturePath;
                    }
                    Utilities.addMediaToGallery(currentPicturePath);
                    currentPicturePath = null;
                } else {
                    try {
                        videoPath = Utilities.getPath(uri);
                    } catch (Exception e) {
                        FileLog.e("tmessages", e);
                    }
                }
            }
            if (videoPath == null && currentPicturePath != null) {
                File f = new File(currentPicturePath);
                if (f.exists()) {
                    videoPath = currentPicturePath;
                }
                currentPicturePath = null;
            }
           /* if(android.os.Build.VERSION.SDK_INT >= 10) {
               Bundle args = new Bundle();
                args.putString("videoPath", videoPath);
                VideoEditorActivity fragment = new VideoEditorActivity();
                fragment.setArguments(args);
                fragment.setDelegate(this);
                ((LaunchActivity)parentActivity).presentFragment(fragment,"Video Editor Activity",false);
            } else {*/
            processSendingVideo(videoPath);
            // }

        } else if (requestCode == 21) {
            if (data == null || data.getData() == null) {
                showAttachmentError();
                return;
            }
            String tempPath = Utilities.getPath(data.getData());
            String originalPath = tempPath;
            if (tempPath == null) {
                originalPath = data.toString();
                tempPath = MediaController.copyDocumentToCache(data.getData(), "file");
            }
            if (tempPath == null) {
                showAttachmentError();
                return;
            }
            processSendingDocument(tempPath, originalPath);
        }
    }
}
 
 方法所在类
 同类方法