Java Code Examples for android.content.pm.ResolveInfo

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project android-joedayz, under directory /Proyectos/FBConnectTest/src/com/facebook/android/.

Source file: Facebook.java

  18 
vote

/** 
 * Helper to validate an activity intent by resolving and checking the provider's package signature.
 * @param context
 * @param intent
 * @return true if the service intent resolution happens successfully and thesignatures match.
 */
private boolean validateActivityIntent(Context context,Intent intent){
  ResolveInfo resolveInfo=context.getPackageManager().resolveActivity(intent,0);
  if (resolveInfo == null) {
    return false;
  }
  return validateAppSignatureForPackage(context,resolveInfo.activityInfo.packageName);
}
 

Example 2

From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/.

Source file: ActivityPicker.java

  18 
vote

/** 
 * Fill the given list with any activities matching the base  {@link Intent}. 
 */
protected void putIntentItems(Intent baseIntent,List<PickAdapter.Item> items){
  PackageManager packageManager=getPackageManager();
  List<ResolveInfo> list=packageManager.queryIntentActivities(baseIntent,0);
  Collections.sort(list,new ResolveInfo.DisplayNameComparator(packageManager));
  final int listSize=list.size();
  for (int i=0; i < listSize; i++) {
    ResolveInfo resolveInfo=list.get(i);
    items.add(new PickAdapter.Item(this,packageManager,resolveInfo));
  }
}
 

Example 3

From project android_packages_apps_phone, under directory /src/com/android/phone/.

Source file: OtaStartupReceiver.java

  18 
vote

/** 
 * On devices that provide a phone initialization wizard (such as Google Setup Wizard), we  allow delaying CDMA OTA setup so it can be done in a single wizard. The wizard is responsible for (1) disabling itself once it has been run and/or (2) setting the 'device_provisioned'  flag to something non-zero and (3) calling the OTA Setup with the action below. NB: Typical phone initialization wizards will install themselves as the homescreen (category "android.intent.category.HOME") with a priority higher than the default.   The wizard should set 'device_provisioned' when it completes, disable itself with the PackageManager.setComponentEnabledSetting() and then start home screen.
 * @return true if setup will be handled by wizard, false if it should be done now.
 */
private boolean shouldPostpone(Context context){
  Intent intent=new Intent("android.intent.action.DEVICE_INITIALIZATION_WIZARD");
  ResolveInfo resolveInfo=context.getPackageManager().resolveActivity(intent,PackageManager.MATCH_DEFAULT_ONLY);
  boolean provisioned=Settings.Secure.getInt(context.getContentResolver(),Settings.Secure.DEVICE_PROVISIONED,0) != 0;
  String mode=SystemProperties.get("ro.setupwizard.mode","REQUIRED");
  boolean runningSetupWizard="REQUIRED".equals(mode) || "OPTIONAL".equals(mode);
  if (DBG) {
    Log.v(TAG,"resolvInfo = " + resolveInfo + ", provisioned = "+ provisioned+ ", runningSetupWizard = "+ runningSetupWizard);
  }
  return resolveInfo != null && !provisioned && runningSetupWizard;
}
 

Example 4

From project android_packages_apps_QuickSearchBox, under directory /src/com/android/quicksearchbox/.

Source file: VoiceSearch.java

  18 
vote

/** 
 * Gets the  {@code versionCode} of the currently installed voice search package.
 * @return The {@code versionCode} of voiceSearch, or 0 if none is installed.
 */
public int getVersion(){
  ResolveInfo ri=getResolveInfo();
  if (ri == null)   return 0;
  ComponentInfo ci=ri.activityInfo != null ? ri.activityInfo : ri.serviceInfo;
  try {
    return getContext().getPackageManager().getPackageInfo(ci.packageName,0).versionCode;
  }
 catch (  NameNotFoundException e) {
    Log.e(TAG,"Cannot find voice search package " + ci.packageName,e);
    return 0;
  }
}
 

Example 5

From project android_packages_apps_Tag, under directory /src/com/android/apps/tag/record/.

Source file: UriRecord.java

  18 
vote

/** 
 * Returns a view in a list of record types for adding new records to a message.
 */
public static View getAddView(Context context,LayoutInflater inflater,ViewGroup parent){
  ViewGroup root=(ViewGroup)inflater.inflate(R.layout.tag_add_record_list_item,parent,false);
  Intent intent=new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.google.com"));
  PackageManager pm=context.getPackageManager();
  List<ResolveInfo> activities=pm.queryIntentActivities(intent,0);
  if (activities.isEmpty()) {
    return null;
  }
  ResolveInfo info=activities.get(0);
  ((ImageView)root.findViewById(R.id.image)).setImageDrawable(info.loadIcon(pm));
  ((TextView)root.findViewById(R.id.text)).setText(context.getString(R.string.url));
  root.setTag(new UriRecordEditInfo(""));
  return root;
}
 

Example 6

From project creamed_glacier_app_settings, under directory /src/com/android/settings/.

Source file: AccessibilitySettings.java

  18 
vote

private void loadInstalledServices(){
  List<AccessibilityServiceInfo> installedServiceInfos=AccessibilityManager.getInstance(getActivity()).getInstalledAccessibilityServiceList();
  Set<ComponentName> installedServices=sInstalledServices;
  installedServices.clear();
  final int installedServiceInfoCount=installedServiceInfos.size();
  for (int i=0; i < installedServiceInfoCount; i++) {
    ResolveInfo resolveInfo=installedServiceInfos.get(i).getResolveInfo();
    ComponentName installedService=new ComponentName(resolveInfo.serviceInfo.packageName,resolveInfo.serviceInfo.name);
    installedServices.add(installedService);
  }
}
 

Example 7

From project cw-advandroid, under directory /Introspection/Launchalot/src/com/commonsware/android/launchalot/.

Source file: Launchalot.java

  18 
vote

@Override protected void onListItemClick(ListView l,View v,int position,long id){
  ResolveInfo launchable=adapter.getItem(position);
  ActivityInfo activity=launchable.activityInfo;
  ComponentName name=new ComponentName(activity.applicationInfo.packageName,activity.name);
  Intent i=new Intent(Intent.ACTION_MAIN);
  i.addCategory(Intent.CATEGORY_LAUNCHER);
  i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
  i.setComponent(name);
  startActivity(i);
}
 

Example 8

From project cw-omnibus, under directory /Introspection/Launchalot/src/com/commonsware/android/launchalot/.

Source file: Launchalot.java

  18 
vote

@Override protected void onListItemClick(ListView l,View v,int position,long id){
  ResolveInfo launchable=adapter.getItem(position);
  ActivityInfo activity=launchable.activityInfo;
  ComponentName name=new ComponentName(activity.applicationInfo.packageName,activity.name);
  Intent i=new Intent(Intent.ACTION_MAIN);
  i.addCategory(Intent.CATEGORY_LAUNCHER);
  i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
  i.setComponent(name);
  startActivity(i);
}
 

Example 9

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/.

Source file: ActionMenu.java

  17 
vote

public int addIntentOptions(int groupId,int itemId,int order,ComponentName caller,Intent[] specifics,Intent intent,int flags,MenuItem[] outSpecificItems){
  PackageManager pm=mContext.getPackageManager();
  final List<ResolveInfo> lri=pm.queryIntentActivityOptions(caller,specifics,intent,0);
  final int N=lri != null ? lri.size() : 0;
  if ((flags & FLAG_APPEND_TO_GROUP) == 0) {
    removeGroup(groupId);
  }
  for (int i=0; i < N; i++) {
    final ResolveInfo ri=lri.get(i);
    Intent rintent=new Intent(ri.specificIndex < 0 ? intent : specifics[ri.specificIndex]);
    rintent.setComponent(new ComponentName(ri.activityInfo.applicationInfo.packageName,ri.activityInfo.name));
    final MenuItem item=add(groupId,itemId,order,ri.loadLabel(pm)).setIcon(ri.loadIcon(pm)).setIntent(rintent);
    if (outSpecificItems != null && ri.specificIndex >= 0) {
      outSpecificItems[ri.specificIndex]=item;
    }
  }
  return N;
}
 

Example 10

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/.

Source file: ActionMenu.java

  17 
vote

public int addIntentOptions(int groupId,int itemId,int order,ComponentName caller,Intent[] specifics,Intent intent,int flags,MenuItem[] outSpecificItems){
  PackageManager pm=mContext.getPackageManager();
  final List<ResolveInfo> lri=pm.queryIntentActivityOptions(caller,specifics,intent,0);
  final int N=lri != null ? lri.size() : 0;
  if ((flags & FLAG_APPEND_TO_GROUP) == 0) {
    removeGroup(groupId);
  }
  for (int i=0; i < N; i++) {
    final ResolveInfo ri=lri.get(i);
    Intent rintent=new Intent(ri.specificIndex < 0 ? intent : specifics[ri.specificIndex]);
    rintent.setComponent(new ComponentName(ri.activityInfo.applicationInfo.packageName,ri.activityInfo.name));
    final MenuItem item=add(groupId,itemId,order,ri.loadLabel(pm)).setIcon(ri.loadIcon(pm)).setIntent(rintent);
    if (outSpecificItems != null && ri.specificIndex >= 0) {
      outSpecificItems[ri.specificIndex]=item;
    }
  }
  return N;
}
 

Example 11

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/internal/view/menu/.

Source file: ActionMenu.java

  17 
vote

public int addIntentOptions(int groupId,int itemId,int order,ComponentName caller,Intent[] specifics,Intent intent,int flags,MenuItem[] outSpecificItems){
  PackageManager pm=mContext.getPackageManager();
  final List<ResolveInfo> lri=pm.queryIntentActivityOptions(caller,specifics,intent,0);
  final int N=lri != null ? lri.size() : 0;
  if ((flags & FLAG_APPEND_TO_GROUP) == 0) {
    removeGroup(groupId);
  }
  for (int i=0; i < N; i++) {
    final ResolveInfo ri=lri.get(i);
    Intent rintent=new Intent(ri.specificIndex < 0 ? intent : specifics[ri.specificIndex]);
    rintent.setComponent(new ComponentName(ri.activityInfo.applicationInfo.packageName,ri.activityInfo.name));
    final MenuItem item=add(groupId,itemId,order,ri.loadLabel(pm)).setIcon(ri.loadIcon(pm)).setIntent(rintent);
    if (outSpecificItems != null && ri.specificIndex >= 0) {
      outSpecificItems[ri.specificIndex]=item;
    }
  }
  return N;
}
 

Example 12

From project Amantech, under directory /Android/action_bar_sherlock/src/com/actionbarsherlock/internal/view/menu/.

Source file: ActionMenu.java

  17 
vote

public int addIntentOptions(int groupId,int itemId,int order,ComponentName caller,Intent[] specifics,Intent intent,int flags,MenuItem[] outSpecificItems){
  PackageManager pm=mContext.getPackageManager();
  final List<ResolveInfo> lri=pm.queryIntentActivityOptions(caller,specifics,intent,0);
  final int N=lri != null ? lri.size() : 0;
  if ((flags & FLAG_APPEND_TO_GROUP) == 0) {
    removeGroup(groupId);
  }
  for (int i=0; i < N; i++) {
    final ResolveInfo ri=lri.get(i);
    Intent rintent=new Intent(ri.specificIndex < 0 ? intent : specifics[ri.specificIndex]);
    rintent.setComponent(new ComponentName(ri.activityInfo.applicationInfo.packageName,ri.activityInfo.name));
    final MenuItem item=add(groupId,itemId,order,ri.loadLabel(pm)).setIcon(ri.loadIcon(pm)).setIntent(rintent);
    if (outSpecificItems != null && ri.specificIndex >= 0) {
      outSpecificItems[ri.specificIndex]=item;
    }
  }
  return N;
}
 

Example 13

From project andlytics, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/.

Source file: ActionMenu.java

  17 
vote

public int addIntentOptions(int groupId,int itemId,int order,ComponentName caller,Intent[] specifics,Intent intent,int flags,MenuItem[] outSpecificItems){
  PackageManager pm=mContext.getPackageManager();
  final List<ResolveInfo> lri=pm.queryIntentActivityOptions(caller,specifics,intent,0);
  final int N=lri != null ? lri.size() : 0;
  if ((flags & FLAG_APPEND_TO_GROUP) == 0) {
    removeGroup(groupId);
  }
  for (int i=0; i < N; i++) {
    final ResolveInfo ri=lri.get(i);
    Intent rintent=new Intent(ri.specificIndex < 0 ? intent : specifics[ri.specificIndex]);
    rintent.setComponent(new ComponentName(ri.activityInfo.applicationInfo.packageName,ri.activityInfo.name));
    final MenuItem item=add(groupId,itemId,order,ri.loadLabel(pm)).setIcon(ri.loadIcon(pm)).setIntent(rintent);
    if (outSpecificItems != null && ri.specificIndex >= 0) {
      outSpecificItems[ri.specificIndex]=item;
    }
  }
  return N;
}
 

Example 14

From project Android-Simple-Social-Sharing, under directory /SimpleSocialSharing/src/com/nostra13/socialsharing/facebook/extpack/com/facebook/android/.

Source file: Facebook.java

  17 
vote

/** 
 * Query the signature for the application that would be invoked by the given intent and verify that it matches the FB application's signature.
 * @param activity
 * @param intent
 * @param validSignature
 * @return true if the app's signature matches the expected signature.
 */
private boolean validateAppSignatureForIntent(Activity activity,Intent intent){
  ResolveInfo resolveInfo=activity.getPackageManager().resolveActivity(intent,0);
  if (resolveInfo == null) {
    return false;
  }
  String packageName=resolveInfo.activityInfo.packageName;
  PackageInfo packageInfo;
  try {
    packageInfo=activity.getPackageManager().getPackageInfo(packageName,PackageManager.GET_SIGNATURES);
  }
 catch (  NameNotFoundException e) {
    return false;
  }
  for (  Signature signature : packageInfo.signatures) {
    if (signature.toCharsString().equals(FB_APP_SIGNATURE)) {
      return true;
    }
  }
  return false;
}
 

Example 15

From project android-tether, under directory /facebook/src/com/facebook/android/.

Source file: Facebook.java

  17 
vote

/** 
 * Query the signature for the application that would be invoked by the given intent and verify that it matches the FB application's signature.
 * @param context
 * @param intent
 * @param validSignature
 * @return true if the app's signature matches the expected signature.
 */
private boolean validateAppSignatureForIntent(Context context,Intent intent){
  ResolveInfo resolveInfo=context.getPackageManager().resolveActivity(intent,0);
  if (resolveInfo == null) {
    return false;
  }
  String packageName=resolveInfo.activityInfo.packageName;
  PackageInfo packageInfo;
  try {
    packageInfo=context.getPackageManager().getPackageInfo(packageName,PackageManager.GET_SIGNATURES);
  }
 catch (  NameNotFoundException e) {
    return false;
  }
  for (  Signature signature : packageInfo.signatures) {
    if (signature.toCharsString().equals(FB_APP_SIGNATURE)) {
      return true;
    }
  }
  return false;
}
 

Example 16

From project android-wheel, under directory /wheel-demo/src/kankan/wheel/demo/.

Source file: WheelDemo.java

  17 
vote

protected List getData(String prefix){
  List<Map> myData=new ArrayList<Map>();
  Intent mainIntent=new Intent(Intent.ACTION_MAIN,null);
  mainIntent.addCategory("kankan.wheel.WHEEL_SAMPLE");
  PackageManager pm=getPackageManager();
  List<ResolveInfo> list=pm.queryIntentActivities(mainIntent,0);
  if (null == list)   return myData;
  String[] prefixPath;
  if (prefix.equals("")) {
    prefixPath=null;
  }
 else {
    prefixPath=prefix.split("/");
  }
  int len=list.size();
  Map<String,Boolean> entries=new HashMap<String,Boolean>();
  for (int i=0; i < len; i++) {
    ResolveInfo info=list.get(i);
    CharSequence labelSeq=info.loadLabel(pm);
    String label=labelSeq != null ? labelSeq.toString() : info.activityInfo.name;
    if (prefix.length() == 0 || label.startsWith(prefix)) {
      String[] labelPath=label.split("/");
      String nextLabel=prefixPath == null ? labelPath[0] : labelPath[prefixPath.length];
      if ((prefixPath != null ? prefixPath.length : 0) == labelPath.length - 1) {
        addItem(myData,nextLabel,activityIntent(info.activityInfo.applicationInfo.packageName,info.activityInfo.name));
      }
 else {
        if (entries.get(nextLabel) == null) {
          addItem(myData,nextLabel,browseIntent(prefix.equals("") ? nextLabel : prefix + "/" + nextLabel));
          entries.put(nextLabel,true);
        }
      }
    }
  }
  Collections.sort(myData,sDisplayNameComparator);
  return myData;
}
 

Example 17

From project android-wheel-datetime-picker, under directory /src/kankan/wheel/demo/.

Source file: WheelDemo.java

  17 
vote

protected List getData(String prefix){
  List<Map<String,Object>> myData=new ArrayList<Map<String,Object>>();
  Intent mainIntent=new Intent(Intent.ACTION_MAIN,null);
  mainIntent.addCategory("kankan.wheel.WHEEL_SAMPLE");
  PackageManager pm=getPackageManager();
  List<ResolveInfo> list=pm.queryIntentActivities(mainIntent,0);
  if (null == list)   return myData;
  String[] prefixPath;
  if (prefix.equals("")) {
    prefixPath=null;
  }
 else {
    prefixPath=prefix.split("/");
  }
  int len=list.size();
  Map<String,Boolean> entries=new HashMap<String,Boolean>();
  for (int i=0; i < len; i++) {
    ResolveInfo info=list.get(i);
    CharSequence labelSeq=info.loadLabel(pm);
    String label=labelSeq != null ? labelSeq.toString() : info.activityInfo.name;
    if (prefix.length() == 0 || label.startsWith(prefix)) {
      String[] labelPath=label.split("/");
      String nextLabel=prefixPath == null ? labelPath[0] : labelPath[prefixPath.length];
      if ((prefixPath != null ? prefixPath.length : 0) == labelPath.length - 1) {
        addItem(myData,nextLabel,activityIntent(info.activityInfo.applicationInfo.packageName,info.activityInfo.name));
      }
 else {
        if (entries.get(nextLabel) == null) {
          addItem(myData,nextLabel,browseIntent(prefix.equals("") ? nextLabel : prefix + "/" + nextLabel));
          entries.put(nextLabel,true);
        }
      }
    }
  }
  Collections.sort(myData,sDisplayNameComparator);
  return myData;
}
 

Example 18

From project android-wheel_1, under directory /wheel-demo/src/kankan/wheel/demo/.

Source file: WheelDemo.java

  17 
vote

protected List getData(String prefix){
  List<Map> myData=new ArrayList<Map>();
  Intent mainIntent=new Intent(Intent.ACTION_MAIN,null);
  mainIntent.addCategory("kankan.wheel.WHEEL_SAMPLE");
  PackageManager pm=getPackageManager();
  List<ResolveInfo> list=pm.queryIntentActivities(mainIntent,0);
  if (null == list)   return myData;
  String[] prefixPath;
  if (prefix.equals("")) {
    prefixPath=null;
  }
 else {
    prefixPath=prefix.split("/");
  }
  int len=list.size();
  Map<String,Boolean> entries=new HashMap<String,Boolean>();
  for (int i=0; i < len; i++) {
    ResolveInfo info=list.get(i);
    CharSequence labelSeq=info.loadLabel(pm);
    String label=labelSeq != null ? labelSeq.toString() : info.activityInfo.name;
    if (prefix.length() == 0 || label.startsWith(prefix)) {
      String[] labelPath=label.split("/");
      String nextLabel=prefixPath == null ? labelPath[0] : labelPath[prefixPath.length];
      if ((prefixPath != null ? prefixPath.length : 0) == labelPath.length - 1) {
        addItem(myData,nextLabel,activityIntent(info.activityInfo.applicationInfo.packageName,info.activityInfo.name));
      }
 else {
        if (entries.get(nextLabel) == null) {
          addItem(myData,nextLabel,browseIntent(prefix.equals("") ? nextLabel : prefix + "/" + nextLabel));
          entries.put(nextLabel,true);
        }
      }
    }
  }
  Collections.sort(myData,sDisplayNameComparator);
  return myData;
}
 

Example 19

From project androidquery, under directory /auth/com/androidquery/auth/.

Source file: FacebookHandle.java

  17 
vote

private boolean validateAppSignatureForIntent(Context context,Intent intent){
  PackageManager pm=context.getPackageManager();
  ResolveInfo resolveInfo=pm.resolveActivity(intent,0);
  if (resolveInfo == null) {
    return false;
  }
  String packageName=resolveInfo.activityInfo.packageName;
  PackageInfo packageInfo;
  try {
    packageInfo=pm.getPackageInfo(packageName,PackageManager.GET_SIGNATURES);
  }
 catch (  NameNotFoundException e) {
    return false;
  }
  for (  Signature signature : packageInfo.signatures) {
    if (signature.toCharsString().equals(FB_APP_SIGNATURE)) {
      return true;
    }
  }
  return false;
}
 

Example 20

From project androidZenWriter, under directory /library/src/com/actionbarsherlock/internal/view/menu/.

Source file: ActionMenu.java

  17 
vote

public int addIntentOptions(int groupId,int itemId,int order,ComponentName caller,Intent[] specifics,Intent intent,int flags,MenuItem[] outSpecificItems){
  PackageManager pm=mContext.getPackageManager();
  final List<ResolveInfo> lri=pm.queryIntentActivityOptions(caller,specifics,intent,0);
  final int N=lri != null ? lri.size() : 0;
  if ((flags & FLAG_APPEND_TO_GROUP) == 0) {
    removeGroup(groupId);
  }
  for (int i=0; i < N; i++) {
    final ResolveInfo ri=lri.get(i);
    Intent rintent=new Intent(ri.specificIndex < 0 ? intent : specifics[ri.specificIndex]);
    rintent.setComponent(new ComponentName(ri.activityInfo.applicationInfo.packageName,ri.activityInfo.name));
    final MenuItem item=add(groupId,itemId,order,ri.loadLabel(pm)).setIcon(ri.loadIcon(pm)).setIntent(rintent);
    if (outSpecificItems != null && ri.specificIndex >= 0) {
      outSpecificItems[ri.specificIndex]=item;
    }
  }
  return N;
}
 

Example 21

From project android_packages_apps_cmparts, under directory /src/com/cyanogenmod/cmparts/activities/.

Source file: GestureMenuActivity.java

  17 
vote

public static boolean updatePreferenceToSpecificActivityOrRemove(Context context,PreferenceGroup parentPreferenceGroup,String preferenceKey,int flags){
  Preference preference=parentPreferenceGroup.findPreference(preferenceKey);
  if (preference == null) {
    return false;
  }
  Intent intent=preference.getIntent();
  if (intent != null) {
    PackageManager pm=context.getPackageManager();
    List<ResolveInfo> list=pm.queryIntentActivities(intent,0);
    int listSize=list.size();
    for (int i=0; i < listSize; i++) {
      ResolveInfo resolveInfo=list.get(i);
      if ((resolveInfo.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
        preference.setIntent(new Intent().setClassName(resolveInfo.activityInfo.packageName,resolveInfo.activityInfo.name));
        return true;
      }
    }
  }
  parentPreferenceGroup.removePreference(preference);
  return true;
}
 

Example 22

From project android_packages_apps_FileManager, under directory /src/org/openintents/filemanager/.

Source file: FileManagerActivity.java

  17 
vote

/** 
 * @since 2011-09-30
 */
private void showMoreCommandsDialog(){
  final Uri data=Uri.fromFile(mContextFile);
  final Intent intent=new Intent(null,data);
  String type=mMimeTypes.getMimeType(mContextFile.getName());
  intent.setDataAndType(data,type);
  Log.v(TAG,"Data=" + data);
  Log.v(TAG,"Type=" + type);
  if (type != null) {
    PackageManager pm=getPackageManager();
    final List<ResolveInfo> lri=pm.queryIntentActivityOptions(new ComponentName(this,FileManagerActivity.class),null,intent,0);
    final int N=lri != null ? lri.size() : 0;
    final List<CharSequence> items=new ArrayList<CharSequence>();
    List<ResolveInfo> toRemove=new ArrayList<ResolveInfo>();
    for (int i=0; i < N; i++) {
      final ResolveInfo ri=lri.get(i);
      Intent rintent=new Intent(intent);
      rintent.setComponent(new ComponentName(ri.activityInfo.applicationInfo.packageName,ri.activityInfo.name));
      ActivityInfo info=rintent.resolveActivityInfo(pm,0);
      String permission=info.permission;
      if (info.exported && (permission == null || checkCallingPermission(permission) == PackageManager.PERMISSION_GRANTED))       items.add(ri.loadLabel(pm));
 else       toRemove.add(ri);
    }
    for (    ResolveInfo ri : toRemove) {
      lri.remove(ri);
    }
    new AlertDialog.Builder(this).setTitle(mContextText).setIcon(mContextIcon).setItems(items.toArray(new CharSequence[0]),new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int item){
        final ResolveInfo ri=lri.get(item);
        Intent rintent=new Intent(intent).setComponent(new ComponentName(ri.activityInfo.applicationInfo.packageName,ri.activityInfo.name));
        startActivity(rintent);
      }
    }
).create().show();
  }
}
 

Example 23

From project android_packages_apps_Nfc, under directory /src/com/android/nfc/.

Source file: NfcDispatcher.java

  17 
vote

boolean tryTech(DispatchInfo dispatch,Tag tag){
  dispatch.setTechIntent();
  String[] tagTechs=tag.getTechList();
  Arrays.sort(tagTechs);
  ArrayList<ResolveInfo> matches=new ArrayList<ResolveInfo>();
  List<ComponentInfo> registered=mTechListFilters.getComponents();
  for (  ComponentInfo info : registered) {
    if (filterMatch(tagTechs,info.techs) && isComponentEnabled(mPackageManager,info.resolveInfo)) {
      if (!matches.contains(info.resolveInfo)) {
        matches.add(info.resolveInfo);
      }
    }
  }
  if (matches.size() == 1) {
    ResolveInfo info=matches.get(0);
    dispatch.intent.setClassName(info.activityInfo.packageName,info.activityInfo.name);
    if (dispatch.tryStartActivity()) {
      if (DBG)       Log.i(TAG,"matched single TECH");
      return true;
    }
    dispatch.intent.setClassName((String)null,null);
  }
 else   if (matches.size() > 1) {
    Intent intent=new Intent(mContext,TechListChooserActivity.class);
    intent.putExtra(Intent.EXTRA_INTENT,dispatch.intent);
    intent.putParcelableArrayListExtra(TechListChooserActivity.EXTRA_RESOLVE_INFOS,matches);
    if (dispatch.tryStartActivity(intent)) {
      if (DBG)       Log.i(TAG,"matched multiple TECH");
      return true;
    }
  }
  return false;
}
 

Example 24

From project apps-for-android, under directory /AnyCut/src/com/example/anycut/.

Source file: ActivityPickerActivity.java

  17 
vote

@Override protected void onListItemClick(ListView list,View view,int position,long id){
  ResolveInfoWrapper wrapper=(ResolveInfoWrapper)getListAdapter().getItem(position);
  ResolveInfo info=wrapper.getInfo();
  Intent intent=new Intent();
  intent.setComponent(new ComponentName(info.activityInfo.applicationInfo.packageName,info.activityInfo.name));
  Intent result=new Intent();
  result.putExtra(Intent.EXTRA_SHORTCUT_INTENT,intent);
  result.putExtra(Intent.EXTRA_SHORTCUT_NAME,info.loadLabel(mPackageManager));
  Drawable drawable=info.loadIcon(mPackageManager);
  if (drawable instanceof BitmapDrawable) {
    BitmapDrawable bd=(BitmapDrawable)drawable;
    result.putExtra(Intent.EXTRA_SHORTCUT_ICON,bd.getBitmap());
  }
  setResult(RESULT_OK,result);
  finish();
}
 

Example 25

From project cocos2d, under directory /cocos2d-android/src/org/cocos2d/.

Source file: Cocos2D.java

  17 
vote

protected List<?> getData(String prefix){
  List<Map<String,?>> myData=new ArrayList<Map<String,?>>();
  Intent mainIntent=new Intent(Intent.ACTION_MAIN,null);
  mainIntent.addCategory(Intent.CATEGORY_TEST);
  PackageManager pm=getPackageManager();
  List<ResolveInfo> list=pm.queryIntentActivities(mainIntent,0);
  if (null == list)   return myData;
  int len=list.size();
  for (int i=0; i < len; i++) {
    ResolveInfo info=list.get(i);
    String activityName=info.activityInfo.name;
    if (prefix.length() == 0 || activityName.startsWith(prefix)) {
      String[] labelPath=activityName.split("\\.");
      String nextLabel=labelPath[labelPath.length - 1];
      addItem(myData,nextLabel,activityIntent(info.activityInfo.applicationInfo.packageName,info.activityInfo.name));
    }
  }
  Collections.sort(myData,sDisplayNameComparator);
  return myData;
}
 

Example 26

From project Common-Sense-Net-2, under directory /AndroidBarSherlock/src/com/actionbarsherlock/internal/view/menu/.

Source file: ActionMenu.java

  17 
vote

public int addIntentOptions(int groupId,int itemId,int order,ComponentName caller,Intent[] specifics,Intent intent,int flags,MenuItem[] outSpecificItems){
  PackageManager pm=mContext.getPackageManager();
  final List<ResolveInfo> lri=pm.queryIntentActivityOptions(caller,specifics,intent,0);
  final int N=lri != null ? lri.size() : 0;
  if ((flags & FLAG_APPEND_TO_GROUP) == 0) {
    removeGroup(groupId);
  }
  for (int i=0; i < N; i++) {
    final ResolveInfo ri=lri.get(i);
    Intent rintent=new Intent(ri.specificIndex < 0 ? intent : specifics[ri.specificIndex]);
    rintent.setComponent(new ComponentName(ri.activityInfo.applicationInfo.packageName,ri.activityInfo.name));
    final MenuItem item=add(groupId,itemId,order,ri.loadLabel(pm)).setIcon(ri.loadIcon(pm)).setIntent(rintent);
    if (outSpecificItems != null && ri.specificIndex >= 0) {
      outSpecificItems[ri.specificIndex]=item;
    }
  }
  return N;
}
 

Example 27

From project connectbot, under directory /src/sk/vx/connectbot/.

Source file: TerminalView.java

  17 
vote

@Override protected Boolean doInBackground(Void... params){
  final AccessibilityManager accessibility=(AccessibilityManager)context.getSystemService(Context.ACCESSIBILITY_SERVICE);
  if (!accessibility.isEnabled()) {
    return false;
  }
  final Intent screenReaderIntent=new Intent(SCREENREADER_INTENT_ACTION);
  screenReaderIntent.addCategory(SCREENREADER_INTENT_CATEGORY);
  final ContentResolver cr=context.getContentResolver();
  final List<ResolveInfo> screenReaders=context.getPackageManager().queryIntentServices(screenReaderIntent,0);
  boolean foundScreenReader=false;
  final int N=screenReaders.size();
  for (int i=0; i < N; i++) {
    final ResolveInfo screenReader=screenReaders.get(i);
    final Cursor cursor=cr.query(Uri.parse("content://" + screenReader.serviceInfo.packageName + ".providers.StatusProvider"),null,null,null,null);
    if (cursor != null && cursor.moveToFirst()) {
      final int status=cursor.getInt(0);
      cursor.close();
      if (status == 1) {
        foundScreenReader=true;
        break;
      }
    }
  }
  if (foundScreenReader) {
    mControlCodes=Pattern.compile(CONTROL_CODE_PATTERN);
  }
  return foundScreenReader;
}
 

Example 28

From project cornerstone, under directory /frameworks/base/services/java/com/android/server/am/.

Source file: ActivityManagerService.java

  17 
vote

/** 
 * Starts the "new version setup screen" if appropriate.
 */
void startSetupActivityLocked(){
  if (mCheckedForSetup) {
    return;
  }
  final ContentResolver resolver=mContext.getContentResolver();
  if (mFactoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL && Settings.Secure.getInt(resolver,Settings.Secure.DEVICE_PROVISIONED,0) != 0) {
    mCheckedForSetup=true;
    Intent intent=new Intent(Intent.ACTION_UPGRADE_SETUP);
    List<ResolveInfo> ris=mSelf.mContext.getPackageManager().queryIntentActivities(intent,PackageManager.GET_META_DATA);
    ResolveInfo ri=null;
    for (int i=0; ris != null && i < ris.size(); i++) {
      if ((ris.get(i).activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
        ri=ris.get(i);
        break;
      }
    }
    if (ri != null) {
      String vers=ri.activityInfo.metaData != null ? ri.activityInfo.metaData.getString(Intent.METADATA_SETUP_VERSION) : null;
      if (vers == null && ri.activityInfo.applicationInfo.metaData != null) {
        vers=ri.activityInfo.applicationInfo.metaData.getString(Intent.METADATA_SETUP_VERSION);
      }
      String lastVers=Settings.Secure.getString(resolver,Settings.Secure.LAST_SETUP_SHOWN);
      if (vers != null && !vers.equals(lastVers)) {
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setComponent(new ComponentName(ri.activityInfo.packageName,ri.activityInfo.name));
        mMainStack.startActivityLocked(null,intent,null,null,0,ri.activityInfo,null,null,0,0,0,false,false,null);
      }
    }
  }
}
 

Example 29

From project COSsettings, under directory /src/com/cyanogenmod/cmparts/activities/.

Source file: GestureMenuActivity.java

  17 
vote

public static boolean updatePreferenceToSpecificActivityOrRemove(Context context,PreferenceGroup parentPreferenceGroup,String preferenceKey,int flags){
  Preference preference=parentPreferenceGroup.findPreference(preferenceKey);
  if (preference == null) {
    return false;
  }
  Intent intent=preference.getIntent();
  if (intent != null) {
    PackageManager pm=context.getPackageManager();
    List<ResolveInfo> list=pm.queryIntentActivities(intent,0);
    int listSize=list.size();
    for (int i=0; i < listSize; i++) {
      ResolveInfo resolveInfo=list.get(i);
      if ((resolveInfo.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
        preference.setIntent(new Intent().setClassName(resolveInfo.activityInfo.packageName,resolveInfo.activityInfo.name));
        return true;
      }
    }
  }
  parentPreferenceGroup.removePreference(preference);
  return true;
}
 

Example 30

From project cow, under directory /libs/ActionBarSherlock/library/src/com/actionbarsherlock/internal/view/menu/.

Source file: ActionMenu.java

  17 
vote

public int addIntentOptions(int groupId,int itemId,int order,ComponentName caller,Intent[] specifics,Intent intent,int flags,MenuItem[] outSpecificItems){
  PackageManager pm=mContext.getPackageManager();
  final List<ResolveInfo> lri=pm.queryIntentActivityOptions(caller,specifics,intent,0);
  final int N=lri != null ? lri.size() : 0;
  if ((flags & FLAG_APPEND_TO_GROUP) == 0) {
    removeGroup(groupId);
  }
  for (int i=0; i < N; i++) {
    final ResolveInfo ri=lri.get(i);
    Intent rintent=new Intent(ri.specificIndex < 0 ? intent : specifics[ri.specificIndex]);
    rintent.setComponent(new ComponentName(ri.activityInfo.applicationInfo.packageName,ri.activityInfo.name));
    final MenuItem item=add(groupId,itemId,order,ri.loadLabel(pm)).setIcon(ri.loadIcon(pm)).setIntent(rintent);
    if (outSpecificItems != null && ri.specificIndex >= 0) {
      outSpecificItems[ri.specificIndex]=item;
    }
  }
  return N;
}
 

Example 31

From project DeskSMS, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/.

Source file: ActionMenu.java

  17 
vote

public int addIntentOptions(int groupId,int itemId,int order,ComponentName caller,Intent[] specifics,Intent intent,int flags,MenuItem[] outSpecificItems){
  PackageManager pm=mContext.getPackageManager();
  final List<ResolveInfo> lri=pm.queryIntentActivityOptions(caller,specifics,intent,0);
  final int N=lri != null ? lri.size() : 0;
  if ((flags & FLAG_APPEND_TO_GROUP) == 0) {
    removeGroup(groupId);
  }
  for (int i=0; i < N; i++) {
    final ResolveInfo ri=lri.get(i);
    Intent rintent=new Intent(ri.specificIndex < 0 ? intent : specifics[ri.specificIndex]);
    rintent.setComponent(new ComponentName(ri.activityInfo.applicationInfo.packageName,ri.activityInfo.name));
    final MenuItem item=add(groupId,itemId,order,ri.loadLabel(pm)).setIcon(ri.loadIcon(pm)).setIntent(rintent);
    if (outSpecificItems != null && ri.specificIndex >= 0) {
      outSpecificItems[ri.specificIndex]=item;
    }
  }
  return N;
}
 

Example 32

From project Airports, under directory /src/com/nadmm/airports/utils/.

Source file: SystemUtils.java

  15 
vote

public static boolean canDisplayMimeType(Context context,String mimeType){
  PackageManager pm=context.getPackageManager();
  Intent intent=new Intent(Intent.ACTION_VIEW);
  intent.setType(mimeType);
  List<ResolveInfo> list=pm.queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY);
  return !list.isEmpty();
}
 

Example 33

From project android-client, under directory /xwiki-android-client/src/org/xwiki/android/client/launcher/.

Source file: IconLaunchPad.java

  15 
vote

public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.launchpad);
  GridView gridview=(GridView)findViewById(R.id.gv_launchpad);
  gridview.setNumColumns(3);
  Intent intent=new Intent(XWikiIntentFilters.ACTION_MAIN);
  List<ResolveInfo> list=getPackageManager().queryIntentActivities(intent,PackageManager.GET_ACTIVITIES);
  List<ImageButton> imgBtns=new ArrayList<ImageButton>();
  int i=0;
  for (  ResolveInfo r : list) {
    int iconId=r.getIconResource();
    ImageButton btn=new ImageButton(this);
    btn.setImageResource(iconId);
    btn.setBackgroundColor(Color.TRANSPARENT);
    imgBtns.add(btn);
    Log.d(this.getClass().getSimpleName(),"Btn for:" + r.activityInfo.name + "icon id is:"+ iconId);
    btn.setTag(r.activityInfo.name);
    btn.setOnClickListener(this);
    i++;
  }
  ImgBtnAdapter adapter=new ImgBtnAdapter(imgBtns);
  gridview.setAdapter(adapter);
}
 

Example 34

From project android-xbmcremote-sandbox, under directory /src/org/xbmc/android/util/.

Source file: UIUtils.java

  15 
vote

public static Drawable getIconForIntent(final Context context,Intent i){
  PackageManager pm=context.getPackageManager();
  List<ResolveInfo> infos=pm.queryIntentActivities(i,PackageManager.MATCH_DEFAULT_ONLY);
  if (infos.size() > 0) {
    return infos.get(0).loadIcon(pm);
  }
  return null;
}
 

Example 35

From project AndroidDevWeekendDub-BookLibrary, under directory /src/org/curiouscreature/android/shelves/scan/.

Source file: ScanIntent.java

  15 
vote

public static boolean isInstalled(Context context){
  final PackageManager packageManager=context.getPackageManager();
  final Intent intent=new Intent(INTENT_ACTION_SCAN);
  List<ResolveInfo> list=packageManager.queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY);
  return list.size() > 0;
}
 

Example 36

From project android_packages_apps_Gallery2, under directory /src/com/android/gallery3d/util/.

Source file: GalleryUtils.java

  15 
vote

public static boolean isEditorAvailable(Context context,String mimeType){
  int version=PackagesMonitor.getPackagesVersion(context);
  String updateKey=PREFIX_PHOTO_EDITOR_UPDATE + mimeType;
  String hasKey=PREFIX_HAS_PHOTO_EDITOR + mimeType;
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(context);
  if (prefs.getInt(updateKey,0) != version) {
    PackageManager packageManager=context.getPackageManager();
    List<ResolveInfo> infos=packageManager.queryIntentActivities(new Intent(Intent.ACTION_EDIT).setType(mimeType),0);
    prefs.edit().putInt(updateKey,version).putBoolean(hasKey,!infos.isEmpty()).commit();
  }
  return prefs.getBoolean(hasKey,true);
}
 

Example 37

From project android_packages_apps_Gallery3D, under directory /src/com/cooliris/media/.

Source file: HudLayer.java

  15 
vote

private void startResolvedActivity(Intent intent,ResolveInfo info){
  final Intent resolvedIntent=new Intent(intent);
  ActivityInfo ai=info.activityInfo;
  resolvedIntent.setComponent(new ComponentName(ai.applicationInfo.packageName,ai.name));
  App.get(mContext).getHandler().post(new Runnable(){
    public void run(){
      mContext.startActivity(resolvedIntent);
    }
  }
);
}
 

Example 38

From project android_packages_apps_TouchWiz30Launcher, under directory /src/com/sec/android/app/twlauncher/.

Source file: ApplicationInfo.java

  15 
vote

public ApplicationInfo(ResolveInfo resolveinfo,IconCache iconcache){
  topNum=65535;
  pageNum=65535;
  cellNum=65535;
  editTopNum=65535;
  editPageNum=65535;
  editCellNum=65535;
  componentName=new ComponentName(resolveinfo.activityInfo.applicationInfo.packageName,resolveinfo.activityInfo.name);
  super.container=-1L;
  setActivity(componentName,0x10200000);
  iconcache.getTitleAndIcon(this,resolveinfo);
}
 

Example 39

From project Anki-Android, under directory /src/com/ichi2/anki/.

Source file: Utils.java

  15 
vote

/** 
 * Indicates whether the specified action can be used as an intent. This method queries the package manager for installed packages that can respond to an intent with the specified action. If no suitable package is found, this method returns false.
 * @param context The application's environment.
 * @param action The Intent action to check for availability.
 * @return True if an Intent with the specified action can be sent and responded to, false otherwise.
 */
public static boolean isIntentAvailable(Context context,String action){
  final PackageManager packageManager=context.getPackageManager();
  final Intent intent=new Intent(action);
  List<ResolveInfo> list=packageManager.queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY);
  return list.size() > 0;
}
 

Example 40

From project AnySoftKeyboard, under directory /src/com/anysoftkeyboard/addons/.

Source file: AddOnsFactory.java

  15 
vote

private ArrayList<E> getExternalAddOns(Context context){
  final ArrayList<E> externalAddOns=new ArrayList<E>();
  if (!mReadExternalPacksToo)   return externalAddOns;
  final List<ResolveInfo> broadcastReceivers=context.getPackageManager().queryBroadcastReceivers(new Intent(RECEIVER_INTERFACE),PackageManager.GET_META_DATA);
  for (  final ResolveInfo receiver : broadcastReceivers) {
    if (receiver.activityInfo == null) {
      Log.e(TAG,"BroadcastReceiver has null ActivityInfo. Receiver's label is " + receiver.loadLabel(context.getPackageManager()));
      Log.e(TAG,"Is the external keyboard a service instead of BroadcastReceiver?");
      continue;
    }
    if (!receiver.activityInfo.enabled || !receiver.activityInfo.applicationInfo.enabled)     continue;
    try {
      final Context externalPackageContext=context.createPackageContext(receiver.activityInfo.packageName,PackageManager.GET_META_DATA);
      final ArrayList<E> packageAddOns=getAddOnsFromActivityInfo(externalPackageContext,receiver.activityInfo);
      externalAddOns.addAll(packageAddOns);
    }
 catch (    final NameNotFoundException e) {
      Log.e(TAG,"Did not find package: " + receiver.activityInfo.packageName);
    }
  }
  return externalAddOns;
}
 

Example 41

From project AquaNotesTest, under directory /src/com/google/android/apps/iosched/ui/.

Source file: BaseMultiPaneActivity.java

  15 
vote

/** 
 * {@inheritDoc} 
 */
@Override public void openActivityOrFragment(final Intent intent){
  final PackageManager pm=getPackageManager();
  List<ResolveInfo> resolveInfoList=pm.queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY);
  for (  ResolveInfo resolveInfo : resolveInfoList) {
    final FragmentReplaceInfo fri=onSubstituteFragmentForActivityLaunch(resolveInfo.activityInfo.name);
    if (fri != null) {
      final Bundle arguments=intentToFragmentArguments(intent);
      final FragmentManager fm=getSupportFragmentManager();
      try {
        Fragment fragment=(Fragment)fri.getFragmentClass().newInstance();
        fragment.setArguments(arguments);
        FragmentTransaction ft=fm.beginTransaction();
        ft.replace(fri.getContainerId(),fragment,fri.getFragmentTag());
        onBeforeCommitReplaceFragment(fm,ft,fragment);
        ft.commit();
      }
 catch (      InstantiationException e) {
        throw new IllegalStateException("Error creating new fragment.",e);
      }
catch (      IllegalAccessException e) {
        throw new IllegalStateException("Error creating new fragment.",e);
      }
      return;
    }
  }
  super.openActivityOrFragment(intent);
}
 

Example 42

From project Cafe, under directory /testservice/src/com/baidu/cafe/remote/.

Source file: SystemLib.java

  15 
vote

/** 
 * @return list of package names
 */
private List<String> getHomePackageNames(){
  Intent intent=new Intent(Intent.ACTION_MAIN);
  intent.addCategory(Intent.CATEGORY_HOME);
  List<String> names=new ArrayList<String>();
  for (  ResolveInfo resolveInfo : mPackageManager.queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY)) {
    names.add(resolveInfo.activityInfo.packageName);
  }
  return names;
}
 

Example 43

From project Catroid-maven-playground, under directory /src/main/java/at/tugraz/ist/catroid/ui/.

Source file: CostumeActivity.java

  15 
vote

public void handleEditCostumeButton(View v){
  Intent intent=new Intent("android.intent.action.MAIN");
  intent.setComponent(new ComponentName("at.tugraz.ist.paintroid","at.tugraz.ist.paintroid.MainActivity"));
  List<ResolveInfo> packageList=getPackageManager().queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY);
  if (packageList.size() <= 0) {
    AlertDialog.Builder builder=new AlertDialog.Builder(this);
    builder.setMessage(getString(R.string.paintroid_not_installed)).setCancelable(false).setPositiveButton(getString(R.string.yes),new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int id){
        Intent downloadPaintroidIntent=new Intent(Intent.ACTION_VIEW,Uri.parse(Constants.PAINTROID_DOWNLOAD_LINK));
        startActivity(downloadPaintroidIntent);
      }
    }
).setNegativeButton(getString(R.string.no),new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int id){
        dialog.cancel();
      }
    }
);
    AlertDialog alert=builder.create();
    alert.show();
    return;
  }
  int position=(Integer)v.getTag();
  ScriptTabActivity scriptTabActivity=(ScriptTabActivity)getParent();
  scriptTabActivity.selectedCostumeData=costumeDataList.get(position);
  Bundle bundleForPaintroid=new Bundle();
  bundleForPaintroid.putString(Constants.EXTRA_PICTURE_PATH_PAINTROID,costumeDataList.get(position).getAbsolutePath());
  bundleForPaintroid.putInt(Constants.EXTRA_X_VALUE_PAINTROID,0);
  bundleForPaintroid.putInt(Constants.EXTRA_X_VALUE_PAINTROID,0);
  intent.putExtras(bundleForPaintroid);
  intent.addCategory("android.intent.category.LAUNCHER");
  startActivityForResult(intent,REQUEST_PAINTROID_EDIT_IMAGE);
}
 

Example 44

From project CineShowTime-Android, under directory /Libraries/CineShowTime/src/com/binomed/showtime/android/layout/view/.

Source file: AutoCompleteTextWithSpeech.java

  15 
vote

private void init(Context context,AttributeSet attrs){
  LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  inflater.inflate(R.layout.view_auto_complete_with_speech,this);
  PackageManager pm=context.getPackageManager();
  List<ResolveInfo> activities=pm.queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH),0);
  RelativeLayout layoutWithSpeech=(RelativeLayout)findViewById(R.id.layoutWithSpeech);
  AutoCompleteTextView autoCompleteTextWithSpeech=(AutoCompleteTextView)findViewById(R.id.searchWithSpeech);
  ImageButton btnSpeech=(ImageButton)findViewById(R.id.btnSpeech);
  AutoCompleteTextView autoCompleteTextWithoutSpeech=(AutoCompleteTextView)findViewById(R.id.searchWithoutSpeech);
  if (activities.size() == 0) {
    layoutWithSpeech.setVisibility(View.GONE);
    autoCompleteText=autoCompleteTextWithoutSpeech;
  }
 else {
    autoCompleteTextWithoutSpeech.setVisibility(View.GONE);
    autoCompleteText=autoCompleteTextWithSpeech;
    btnSpeech.setOnClickListener(this);
  }
  autoCompleteText.setOnEditorActionListener(this);
}
 

Example 45

From project conference-mobile-app, under directory /android-app/src/com/google/android/apps/iosched/ui/.

Source file: BaseMultiPaneActivity.java

  15 
vote

/** 
 * {@inheritDoc} 
 */
@Override public void openActivityOrFragment(final Intent intent){
  final PackageManager pm=getPackageManager();
  List<ResolveInfo> resolveInfoList=pm.queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY);
  for (  ResolveInfo resolveInfo : resolveInfoList) {
    final FragmentReplaceInfo fri=onSubstituteFragmentForActivityLaunch(resolveInfo.activityInfo.name);
    if (fri != null) {
      final Bundle arguments=intentToFragmentArguments(intent);
      final FragmentManager fm=getSupportFragmentManager();
      try {
        Fragment fragment=(Fragment)fri.getFragmentClass().newInstance();
        fragment.setArguments(arguments);
        FragmentTransaction ft=fm.beginTransaction();
        ft.replace(fri.getContainerId(),fragment,fri.getFragmentTag());
        onBeforeCommitReplaceFragment(fm,ft,fragment);
        ft.commit();
      }
 catch (      InstantiationException e) {
        throw new IllegalStateException("Error creating new fragment.",e);
      }
catch (      IllegalAccessException e) {
        throw new IllegalStateException("Error creating new fragment.",e);
      }
      return;
    }
  }
  super.openActivityOrFragment(intent);
}
 

Example 46

From project dcnyc10-android, under directory /android/src/com/lullabot/android/apps/iosched/ui/.

Source file: BaseMultiPaneActivity.java

  15 
vote

/** 
 * {@inheritDoc} 
 */
@Override public void openActivityOrFragment(final Intent intent){
  final PackageManager pm=getPackageManager();
  List<ResolveInfo> resolveInfoList=pm.queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY);
  for (  ResolveInfo resolveInfo : resolveInfoList) {
    final FragmentReplaceInfo fri=onSubstituteFragmentForActivityLaunch(resolveInfo.activityInfo.name);
    if (fri != null) {
      final Bundle arguments=intentToFragmentArguments(intent);
      final FragmentManager fm=getSupportFragmentManager();
      try {
        Fragment fragment=(Fragment)fri.getFragmentClass().newInstance();
        fragment.setArguments(arguments);
        FragmentTransaction ft=fm.beginTransaction();
        ft.replace(fri.getContainerId(),fragment,fri.getFragmentTag());
        onBeforeCommitReplaceFragment(fm,ft,fragment);
        ft.commit();
      }
 catch (      InstantiationException e) {
        throw new IllegalStateException("Error creating new fragment.",e);
      }
catch (      IllegalAccessException e) {
        throw new IllegalStateException("Error creating new fragment.",e);
      }
      return;
    }
  }
  super.openActivityOrFragment(intent);
}