send Badge To VIVO - Android Hardware

Android examples for Hardware:Vendor

Description

send Badge To VIVO

Demo Code


import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.PowerManager;
import android.os.Vibrator;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.List;

public class Main{
    public static void sendBadgeToVIVO(int number) {
        Context context = App.getInstance();
        Intent localIntent = new Intent(
                "launcher.action.CHANGE_APPLICATION_NOTIFICATION_NUM");
        localIntent.putExtra("notificationNum", number);//??
        localIntent.putExtra("packageName", context.getPackageName());//????
        localIntent.putExtra("className", getLauncherClassName(context)); //?????
        context.sendBroadcast(localIntent);
    }// w  ww  .j ava 2 s .  c  om
    public static String getLauncherClassName(Context context) {

        PackageManager pm = context.getPackageManager();

        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);

        List<ResolveInfo> resolveInfos = pm
                .queryIntentActivities(intent, 0);
        for (ResolveInfo resolveInfo : resolveInfos) {
            String pkgName = resolveInfo.activityInfo.applicationInfo.packageName;
            if (pkgName.equalsIgnoreCase(context.getPackageName())) {
                String className = resolveInfo.activityInfo.name;
                return className;
            }
        }
        return null;
    }
}

Related Tutorials