Java Code Examples for android.content.Intent#toString()

The following examples show how to use android.content.Intent#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XiaomiHomeBadger.java    From AndroidBase with Apache License 2.0 6 votes vote down vote up
@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());
        }
    }
}
 
Example 2
Source File: SMSProcessService.java    From BlackList with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: OPPOHomeBader.java    From AndroidBase with Apache License 2.0 6 votes vote down vote up
@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());
            }
        }
    }
}
 
Example 4
Source File: OPPOHomeBader.java    From AndroidAnimationExercise with Apache License 2.0 6 votes vote down vote up
@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());
            }
        }
    }
}
 
Example 5
Source File: XiaomiHomeBadger.java    From AndroidAnimationExercise with Apache License 2.0 6 votes vote down vote up
@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());
        }
    }
}
 
Example 6
Source File: NewHtcHomeBadger.java    From AndroidBase with Apache License 2.0 6 votes vote down vote up
@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());
    }
}
 
Example 7
Source File: LGHomeBadger.java    From AndroidBase with Apache License 2.0 5 votes vote down vote up
@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());
    }
}
 
Example 8
Source File: VIVOHomeBader.java    From AndroidBase with Apache License 2.0 5 votes vote down vote up
@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());
    }
}
 
Example 9
Source File: DefaultBadger.java    From AndroidBase with Apache License 2.0 5 votes vote down vote up
@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());
    }
}
 
Example 10
Source File: AsusHomeLauncher.java    From AndroidBase with Apache License 2.0 5 votes vote down vote up
@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());
    }
}
 
Example 11
Source File: AdwHomeBadger.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
@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());
    }
}
 
Example 12
Source File: AsusHomeLauncher.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
@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());
    }
}
 
Example 13
Source File: LGHomeBadger.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
@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());
    }
}
 
Example 14
Source File: DefaultBadger.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
@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());
    }
}
 
Example 15
Source File: ApexHomeBadger.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
@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());
    }
}
 
Example 16
Source File: SamsungModelImpl.java    From BadgeForAppIcon with MIT License 5 votes vote down vote up
@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;
}
 
Example 17
Source File: MainActivity.java    From GotoSleep with GNU General Public License v3.0 5 votes vote down vote up
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 */
    }
}
 
Example 18
Source File: AdwHomeBadger.java    From AndroidBase with Apache License 2.0 5 votes vote down vote up
@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());
    }
}
 
Example 19
Source File: ChatActivity.java    From Yahala-Messenger with MIT License 4 votes vote down vote up
@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);
        }
    }
}
 
Example 20
Source File: SafeActivityOptions.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private String getIntentString(Intent intent) {
    return intent != null ? intent.toString() : "(no intent)";
}