调用google cloud print

阅读更多

判断本地是否安装某个应用,如果没有安装,则打开google play store:

    boolean isInstalledPrintShare(String packageName){
        boolean installed = false;
        if(TextUtils.isEmpty(packageName)){
            return installed;
        }
        try {
            getPackageManager().getPackageInfo(packageName, android.content.pm.PackageManager.GET_ACTIVITIES);
            installed = true;
        } catch (NameNotFoundException e) {
            try{            
                Uri m_uri = Uri.parse("market://details?id="+ packageName);
                Intent m_intent = new Intent(Intent.ACTION_VIEW, m_uri);
                startActivity(m_intent);
            }catch(Exception e1){
                 Uri m_uri = Uri.parse("https://market.android.com/details?id="+packageName);
                 Intent m_intent = new Intent(Intent.ACTION_VIEW, m_uri);
                 startActivity(m_intent);
            }
        }
        return installed;
    }
调用 google cloud print:

Intent printIntent = new Intent();
printIntent.setAction(Intent.ACTION_SEND);               
String docMimeType = "application/pdf";               
printIntent.setType(docMimeType);
String docTitle = "Print Task Title";
printIntent.putExtra("android.intent.extra.STREAM", docUri);
printIntent.putExtra("title", docTitle);
printIntent.setComponent( new ComponentName(packageNameOfPrinter, "com.google.android.apps.cloudprint.printdialog.CloudPrintLauncherActivity"));
startActivity(printIntent);

 

你可能感兴趣的:(调用google cloud print)