Beispiel #1
0
  public static void SetFileExplorerLink(
      TextView txtFilename, Spanned htmlString, final String pathToLinkTo, final Context context) {

    final Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(Uri.parse("file://" + pathToLinkTo), "resource/folder");
    intent.setAction(Intent.ACTION_VIEW);

    if (intent.resolveActivity(context.getPackageManager()) != null) {
      txtFilename.setLinksClickable(true);
      txtFilename.setClickable(true);
      txtFilename.setMovementMethod(LinkMovementMethod.getInstance());
      txtFilename.setSelectAllOnFocus(false);
      txtFilename.setTextIsSelectable(false);
      txtFilename.setText(htmlString);

      txtFilename.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              context.startActivity(intent);
            }
          });
    }
  }
Beispiel #2
0
 public static boolean IsPackageInstalled(String targetPackage, Context context) {
   List<ApplicationInfo> packages;
   PackageManager pm;
   pm = context.getPackageManager();
   packages = pm.getInstalledApplications(0);
   for (ApplicationInfo packageInfo : packages) {
     if (packageInfo.packageName.equals(targetPackage)) return true;
   }
   return false;
 }
Beispiel #3
0
 /**
  * @param context
  * @return
  */
 public static String version(final Context context) {
   String version = null;
   try {
     final PackageInfo packageinfo =
         context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
     version = packageinfo.versionName;
   } catch (Exception x) {
     DBG.m(x);
   }
   return version;
 }
Beispiel #4
0
	public AppAdapter(Context context, int textViewResourceId , ArrayList<ApplicationInfo> nInfo) {
		super(context,textViewResourceId,nInfo);
		nList = nInfo;
		C = 0;
		msg = new Message();
		MULTI_APPS = new ArrayList<ApplicationInfo>();
		MULTI_SELECT = false;
		thumbSelection = new boolean[nList.size()];
		mContext = context;
		inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		nPManager = context.getPackageManager();
	}
Beispiel #5
0
  /**
   * Starts the setup process. This will start up the setup process asynchronously. You will be
   * notified through the listener when the setup process is complete. This method is safe to call
   * from a UI thread.
   *
   * @param listener The listener to notify when the setup process is complete.
   */
  public void startSetup(final OnSetupFinishedListener listener) {
    if (connection == null) {
      connection = new Connection(listener);
      Intent intent = new Intent("com.android.vending.billing.InAppBillingService.BIND");

      if (!context.getPackageManager().queryIntentServices(intent, 0).isEmpty()) {
        context.bindService(intent, connection, Context.BIND_AUTO_CREATE);
      } else if (listener != null) {
        String message = context.getString(R.string.billing_service_unavailable);
        Result result = new Result(BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE, message);
        listener.onSetupFinished(result);
      }
    }
  }
Beispiel #6
0
 /**
  * @param context
  * @return
  */
 public static String getApplicationName(final Context context) {
   String name = null;
   try {
     final PackageManager packagemanager = context.getPackageManager();
     final PackageInfo packageinfo = packagemanager.getPackageInfo(context.getPackageName(), 0);
     name =
         packageinfo.applicationInfo.loadLabel(packagemanager).toString()
             + "("
             + packageinfo.packageName
             + ")";
   } catch (Exception x) {
     DBG.m(x);
   }
   return name;
 }
Beispiel #7
0
  private Bitmap getAppDrawable(String path) throws OutOfMemoryError {
    Bitmap bitsat;
    try {
      PackageManager pm = mContext.getPackageManager();
      PackageInfo pi = pm.getPackageArchiveInfo(path, 0);
      // // the secret are these two lines....
      pi.applicationInfo.sourceDir = path;
      pi.applicationInfo.publicSourceDir = path;
      // //
      Drawable d = pi.applicationInfo.loadIcon(pm);

      Bitmap d1 = null;
      d1 = ((BitmapDrawable) d).getBitmap();
      bitsat = d1;
    } catch (Exception e) {
      Drawable apk = ContextCompat.getDrawable(mContext, R.drawable.ic_doc_apk_grid);
      Bitmap apk1 = ((BitmapDrawable) apk).getBitmap();
      bitsat = apk1;
    }
    return bitsat;
  }
Beispiel #8
0
    /**
     * Starts the setup process. This will start up the setup process asynchronously.
     * You will be notified through the listener when the setup process is complete.
     * This method is safe to call from a UI thread.
     *
     * @param listener The listener to notify when the setup process is complete.
     */
    public void startSetup(final OnIabSetupFinishedListener listener) {
        // If already set up, can't do it again.
        checkNotDisposed();
        if (mSetupDone) throw new IllegalStateException("IAB helper is already set up.");

        // Connection to IAB service
        logDebug("Starting in-app billing setup.");
        mServiceConn = new ServiceConnection() {
            @Override
            public void onServiceDisconnected(ComponentName name) {
                logDebug("Billing service disconnected.");
                mService = null;
            }

            @Override
            public void onServiceConnected(ComponentName name, IBinder service) {
                if (mDisposed) return;
                logDebug("Billing service connected.");
                mService = IInAppBillingService.Stub.asInterface(service);
                String packageName = mContext.getPackageName();
                try {
                    logDebug("Checking for in-app billing 3 support.");

                    // check for in-app billing v3 support
                    int response = mService.isBillingSupported(3, packageName, ITEM_TYPE_INAPP);
                    if (response != BILLING_RESPONSE_RESULT_OK) {
                        if (listener != null) listener.onIabSetupFinished(new IabResult(response,
                                "Error checking for billing v3 support."));

                        // if in-app purchases aren't supported, neither are subscriptions.
                        mSubscriptionsSupported = false;
                        return;
                    }
                    logDebug("In-app billing version 3 supported for " + packageName);

                    // check for v3 subscriptions support
                    response = mService.isBillingSupported(3, packageName, ITEM_TYPE_SUBS);
                    if (response == BILLING_RESPONSE_RESULT_OK) {
                        logDebug("Subscriptions AVAILABLE.");
                        mSubscriptionsSupported = true;
                    }
                    else {
                        logDebug("Subscriptions NOT AVAILABLE. Response: " + response);
                    }

                    mSetupDone = true;
                }
                catch (RemoteException e) {
                    if (listener != null) {
                        listener.onIabSetupFinished(new IabResult(IABHELPER_REMOTE_EXCEPTION,
                                                    "RemoteException while setting up in-app billing."));
                    }
                    e.printStackTrace();
                    return;
                }

                if (listener != null) {
                    listener.onIabSetupFinished(new IabResult(BILLING_RESPONSE_RESULT_OK, "Setup successful."));
                }
            }
        };

        Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
        serviceIntent.setPackage("com.android.vending");
        if (!mContext.getPackageManager().queryIntentServices(serviceIntent, 0).isEmpty()) {
            // service available to handle that Intent
            mContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
        }
        else {
            // no service available to handle that Intent
            if (listener != null) {
                listener.onIabSetupFinished(
                        new IabResult(BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE,
                        "Billing service unavailable on device."));
            }
        }
    }
 public PackageManager getPackageManager() {
   return mBaseContext.getPackageManager();
 }