Android 应用内跳转QQ客服的工具类

工具类如下:

public class QQUtil {
    public static void toQQServer(Context context){
        try {
            ApplicationInfo info = context.getPackageManager().getApplicationInfo("com.tencent.mobileqq",
                    PackageManager.GET_UNINSTALLED_PACKAGES);
            if (info!=null){
                context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("mqqwpa://im/chat?chat_type=wpa&uin=2472328899&version=1")));
            }
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
            Toast.makeText(context,"本机未安装QQ应用",Toast.LENGTH_SHORT).show();
        }
    }
}

使用方法:

   QQUtil.toQQServer(this);

 非常简单,大家有空可以试一下!

猜你喜欢

转载自blog.csdn.net/wolfking0608/article/details/83510313