Java Code Examples for android.content.pm.ActivityInfo

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_aosp_packages_apps_Settings, under directory /src/com/android/settings/quicklaunch/.

Source file: BookmarkPicker.java

  18 
vote

private static Intent getIntentForResolveInfo(ResolveInfo info,String action){
  Intent intent=new Intent(action);
  ActivityInfo ai=info.activityInfo;
  intent.setClassName(ai.packageName,ai.name);
  return intent;
}
 

Example 2

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

Source file: ShortcutPickHelper.java

  18 
vote

private String getFriendlyActivityName(Intent intent,boolean labelOnly){
  PackageManager pm=mParent.getPackageManager();
  ActivityInfo ai=intent.resolveActivityInfo(pm,PackageManager.GET_ACTIVITIES);
  String friendlyName=null;
  if (ai != null) {
    friendlyName=ai.loadLabel(pm).toString();
    if (friendlyName == null && !labelOnly) {
      friendlyName=ai.name;
    }
  }
  return friendlyName != null || labelOnly ? friendlyName : intent.toUri(0);
}
 

Example 3

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

Source file: HudLayer.java

  18 
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 4

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

Source file: AppsCorpus.java

  18 
vote

/** 
 * Creates an intent that starts the search activity specified in R.string.apps_search_activity.
 * @return An intent, or {@code null} if the search activity is not set or can't be found.
 */
private Intent createAppSearchIntent(String query,Bundle appData){
  ComponentName name=getComponentName(getContext(),R.string.apps_search_activity);
  if (name == null)   return null;
  Intent intent=AbstractSource.createSourceSearchIntent(name,query,appData);
  if (intent == null)   return null;
  ActivityInfo ai=intent.resolveActivityInfo(getContext().getPackageManager(),0);
  if (ai != null) {
    return intent;
  }
 else {
    Log.w(TAG,"Can't find app search activity " + name);
    return null;
  }
}
 

Example 5

From project apps-for-android, under directory /RingsExtended/src/com/example/android/rings_extended/.

Source file: RingsExtended.java

  18 
vote

/** 
 * Returns the Intent corresponding to the given position, or null if that position is not an Intent item (that is if it is one of the static list items).
 */
public Intent intentForPosition(int position){
  position-=getIntentStartIndex();
  if (mList == null || position < 0) {
    return null;
  }
  Intent intent=new Intent(position >= mRealListStart ? mIntent : mOrigIntent);
  ActivityInfo ai=mList.get(position).activityInfo;
  intent.setComponent(new ComponentName(ai.applicationInfo.packageName,ai.name));
  return intent;
}
 

Example 6

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

Source file: ShortcutPickHelper.java

  18 
vote

private String getFriendlyActivityName(Intent intent,boolean labelOnly){
  PackageManager pm=mParent.getPackageManager();
  ActivityInfo ai=intent.resolveActivityInfo(pm,PackageManager.GET_ACTIVITIES);
  String friendlyName=null;
  if (ai != null) {
    friendlyName=ai.loadLabel(pm).toString();
    if (friendlyName == null && !labelOnly) {
      friendlyName=ai.name;
    }
  }
  return friendlyName != null || labelOnly ? friendlyName : intent.toUri(0);
}
 

Example 7

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

Source file: BookmarkPicker.java

  18 
vote

private static Intent getIntentForResolveInfo(ResolveInfo info,String action){
  Intent intent=new Intent(action);
  ActivityInfo ai=info.activityInfo;
  intent.setClassName(ai.packageName,ai.name);
  return intent;
}
 

Example 8

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 9

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 10

From project Hax-Launcher, under directory /src/com/t3hh4xx0r/haxlauncher/.

Source file: AllAppsList.java

  18 
vote

/** 
 * Returns whether <em>apps</em> contains <em>component</em>.
 */
private static boolean findActivity(List<ResolveInfo> apps,ComponentName component){
  final String className=component.getClassName();
  for (  ResolveInfo info : apps) {
    final ActivityInfo activityInfo=info.activityInfo;
    if (activityInfo.name.equals(className)) {
      return true;
    }
  }
  return false;
}
 

Example 11

From project HeLauncher, under directory /src/com/handlerexploit/launcher_reloaded/.

Source file: LauncherModel.java

  18 
vote

private static boolean findIntent(List<ResolveInfo> apps,ComponentName component){
  final String className=component.getClassName();
  for (  ResolveInfo info : apps) {
    final ActivityInfo activityInfo=info.activityInfo;
    if (activityInfo.name.equals(className)) {
      return true;
    }
  }
  return false;
}
 

Example 12

From project lastfm-android, under directory /app/src/fm/last/android/activity/.

Source file: ShareResolverActivity.java

  18 
vote

public Intent intentForPosition(int position){
  if (mList == null) {
    return null;
  }
  Intent intent=new Intent(mIntent);
  intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
  ActivityInfo ai=mList.get(position).ri.activityInfo;
  intent.setComponent(new ComponentName(ai.applicationInfo.packageName,ai.name));
  return intent;
}
 

Example 13

From project packages_apps_BlackICEControl, under directory /src/com/blackice/control/util/.

Source file: ShortcutPickerHelper.java

  18 
vote

private String getFriendlyActivityName(Intent intent,boolean labelOnly){
  PackageManager pm=mParent.getActivity().getPackageManager();
  ActivityInfo ai=intent.resolveActivityInfo(pm,PackageManager.GET_ACTIVITIES);
  String friendlyName=null;
  if (ai != null) {
    friendlyName=ai.loadLabel(pm).toString();
    if (friendlyName == null && !labelOnly) {
      friendlyName=ai.name;
    }
  }
  return friendlyName != null || labelOnly ? friendlyName : intent.toUri(0);
}
 

Example 14

From project packages_apps_ROMControl, under directory /src/com/aokp/romcontrol/util/.

Source file: ShortcutPickerHelper.java

  18 
vote

private String getFriendlyActivityName(Intent intent,boolean labelOnly){
  PackageManager pm=mParent.getActivity().getPackageManager();
  ActivityInfo ai=intent.resolveActivityInfo(pm,PackageManager.GET_ACTIVITIES);
  String friendlyName=null;
  if (ai != null) {
    friendlyName=ai.loadLabel(pm).toString();
    if (friendlyName == null && !labelOnly) {
      friendlyName=ai.name;
    }
  }
  return friendlyName != null || labelOnly ? friendlyName : intent.toUri(0);
}
 

Example 15

From project platform_frameworks_support, under directory /v4/java/android/support/v4/app/.

Source file: NavUtils.java

  18 
vote

/** 
 * Return the fully qualified class name of a source activity's parent activity as specified by a  {@link #PARENT_ACTIVITY} &lt;meta-data&gt; element within the activity element inthe application's manifest. The source activity is provided by componentName.
 * @param context Context for looking up the activity component for the source activity
 * @param componentName ComponentName for the source Activity
 * @return The fully qualified class name of sourceActivity's parent activity or null ifit was not specified
 */
public static String getParentActivityName(Context context,ComponentName componentName) throws NameNotFoundException {
  PackageManager pm=context.getPackageManager();
  ActivityInfo info=pm.getActivityInfo(componentName,PackageManager.GET_META_DATA);
  String parentActivity=IMPL.getParentActivityName(context,info);
  return parentActivity;
}
 

Example 16

From project platform_packages_apps_browser, under directory /src/com/android/browser/search/.

Source file: DefaultSearchEngine.java

  18 
vote

private CharSequence loadLabel(Context context,ComponentName activityName){
  PackageManager pm=context.getPackageManager();
  try {
    ActivityInfo ai=pm.getActivityInfo(activityName,0);
    return ai.loadLabel(pm);
  }
 catch (  PackageManager.NameNotFoundException ex) {
    Log.e(TAG,"Web search activity not found: " + activityName);
    return null;
  }
}
 

Example 17

From project platform_packages_apps_launcher, under directory /src/com/android/launcher/.

Source file: LauncherModel.java

  18 
vote

private static boolean findIntent(List<ResolveInfo> apps,ComponentName component){
  final String className=component.getClassName();
  for (  ResolveInfo info : apps) {
    final ActivityInfo activityInfo=info.activityInfo;
    if (activityInfo.name.equals(className)) {
      return true;
    }
  }
  return false;
}
 

Example 18

From project platform_packages_apps_settings, under directory /src/com/android/settings/quicklaunch/.

Source file: BookmarkPicker.java

  18 
vote

private static Intent getIntentForResolveInfo(ResolveInfo info,String action){
  Intent intent=new Intent(action);
  ActivityInfo ai=info.activityInfo;
  intent.setClassName(ai.packageName,ai.name);
  return intent;
}
 

Example 19

From project platform_packages_providers_contactsprovider, under directory /src/com/android/providers/contacts/.

Source file: DbModifierWithNotification.java

  18 
vote

/** 
 * Determines the components that can possibly receive the specified intent. 
 */
private List<ComponentName> getBroadcastReceiverComponents(String intentAction,Uri uri){
  Intent intent=new Intent(intentAction,uri);
  List<ComponentName> receiverComponents=new ArrayList<ComponentName>();
  for (  ResolveInfo resolveInfo : mContext.getPackageManager().queryBroadcastReceivers(intent,0)) {
    ActivityInfo activityInfo=resolveInfo.activityInfo;
    receiverComponents.add(new ComponentName(activityInfo.packageName,activityInfo.name));
  }
  return receiverComponents;
}
 

Example 20

From project RA_Launcher, under directory /src/com/android/ra/launcher/.

Source file: ActivityPickerActivity.java

  18 
vote

public View getChildView(int groupPosition,int childPosition,boolean isLastChild,View convertView,ViewGroup parent){
  TextView textView=getGenericView();
  ActivityInfo activity=getChild(groupPosition,childPosition);
  if (activity != null) {
    String name=activity.name.replace(activity.packageName,"");
    textView.setText(activity.loadLabel(mPackageManager) + "(" + name+ ")");
    textView.setLayoutParams(lpChild);
  }
  return textView;
}
 

Example 21

From project RebeLauncher, under directory /src/com/dirtypepper/rebelauncher/.

Source file: ActivityPickerActivity.java

  18 
vote

public View getChildView(int groupPosition,int childPosition,boolean isLastChild,View convertView,ViewGroup parent){
  TextView textView=getGenericView();
  ActivityInfo activity=getChild(groupPosition,childPosition);
  if (activity != null) {
    String name=activity.name.replace(activity.packageName,"");
    textView.setText(activity.loadLabel(mPackageManager) + "(" + name+ ")");
    textView.setLayoutParams(lpChild);
  }
  return textView;
}
 

Example 22

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/widget/.

Source file: SuggestionsAdapter.java

  17 
vote

/** 
 * Gets the activity or application icon for an activity.
 * @param component Name of an activity.
 * @return A drawable, or {@code null} if neither the acitivy or the applicationhave an icon set.
 */
private Drawable getActivityIcon(ComponentName component){
  PackageManager pm=mContext.getPackageManager();
  final ActivityInfo activityInfo;
  try {
    activityInfo=pm.getActivityInfo(component,PackageManager.GET_META_DATA);
  }
 catch (  NameNotFoundException ex) {
    Log.w(LOG_TAG,ex.toString());
    return null;
  }
  int iconId=activityInfo.getIconResource();
  if (iconId == 0)   return null;
  String pkg=component.getPackageName();
  Drawable drawable=pm.getDrawable(pkg,iconId,activityInfo.applicationInfo);
  if (drawable == null) {
    Log.w(LOG_TAG,"Invalid icon resource " + iconId + " for "+ component.flattenToShortString());
    return null;
  }
  return drawable;
}
 

Example 23

From project android-joedayz, under directory /Proyectos/GreenDroid/src/greendroid/app/.

Source file: GDActivity.java

  17 
vote

public void onPostContentChanged(){
  boolean titleSet=false;
  final Intent intent=getIntent();
  if (intent != null) {
    String title=intent.getStringExtra(ActionBarActivity.GD_ACTION_BAR_TITLE);
    if (title != null) {
      titleSet=true;
      setTitle(title);
    }
  }
  if (!titleSet) {
    try {
      final ActivityInfo activityInfo=getPackageManager().getActivityInfo(getComponentName(),0);
      if (activityInfo.labelRes != 0) {
        setTitle(activityInfo.labelRes);
      }
    }
 catch (    NameNotFoundException e) {
    }
  }
  final int visibility=intent.getIntExtra(ActionBarActivity.GD_ACTION_BAR_VISIBILITY,View.VISIBLE);
  getActionBar().setVisibility(visibility);
}
 

Example 24

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 25

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

Source file: RegisteredComponentCache.java

  17 
vote

void parseComponentInfo(ResolveInfo info,ArrayList<ComponentInfo> components) throws XmlPullParserException, IOException {
  ActivityInfo ai=info.activityInfo;
  PackageManager pm=mContext.getPackageManager();
  XmlResourceParser parser=null;
  try {
    parser=ai.loadXmlMetaData(pm,mMetaDataName);
    if (parser == null) {
      throw new XmlPullParserException("No " + mMetaDataName + " meta-data");
    }
    parseTechLists(pm.getResourcesForApplication(ai.applicationInfo),ai.packageName,parser,info,components);
  }
 catch (  NameNotFoundException e) {
    throw new XmlPullParserException("Unable to load resources for " + ai.packageName);
  }
 finally {
    if (parser != null)     parser.close();
  }
}
 

Example 26

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

Source file: RecordUtils.java

  17 
vote

/** 
 * Build a view to display a single activity that can handle this URI.
 */
private static View buildActivityView(Activity activity,ResolveInfo resolveInfo,PackageManager pm,LayoutInflater inflater,ViewGroup parent,OnClickListener listener,Intent intent,String defaultText){
  ActivityInfo activityInfo=resolveInfo.activityInfo;
  intent.setAction(resolveInfo.filter.getAction(0));
  intent.setComponent(new ComponentName(activityInfo.packageName,activityInfo.name));
  View item=inflater.inflate(R.layout.tag_uri,parent,false);
  item.setOnClickListener(listener);
  item.setTag(new ClickInfo(activity,intent));
  ImageView icon=(ImageView)item.findViewById(R.id.icon);
  icon.setImageDrawable(resolveInfo.loadIcon(pm));
  TextView text=(TextView)item.findViewById(R.id.secondary);
  text.setText(resolveInfo.loadLabel(pm));
  text=(TextView)item.findViewById(R.id.primary);
  text.setText(defaultText);
  return item;
}
 

Example 27

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

Source file: AbstractCineShowTimeActivity.java

  17 
vote

@Override public void onPostContentChanged(){
  boolean titleSet=false;
  final Intent intent=getIntent();
  if (intent != null) {
    String title=intent.getStringExtra(ActionBarActivity.GD_ACTION_BAR_TITLE);
    if (title != null) {
      titleSet=true;
      setTitle(title);
    }
  }
  if (!titleSet) {
    try {
      final ActivityInfo activityInfo=getPackageManager().getActivityInfo(getComponentName(),0);
      if (activityInfo.labelRes != 0) {
        setTitle(activityInfo.labelRes);
      }
    }
 catch (    NameNotFoundException e) {
    }
  }
  final int visibility=intent.getIntExtra(ActionBarActivity.GD_ACTION_BAR_VISIBILITY,View.VISIBLE);
  getActionBar().setVisibility(visibility);
}
 

Example 28

From project cornerstone, under directory /frameworks/base/policy/src/com/android/internal/policy/impl/.

Source file: PhoneWindowManager.java

  17 
vote

/** 
 * Return an Intent to launch the currently active dock app as home.  Returns null if the standard home should be launched, which is the case if any of the following is true: <ul> <li>The device is not in either car mode or desk mode <li>The device is in car mode but ENABLE_CAR_DOCK_HOME_CAPTURE is false <li>The device is in desk mode but ENABLE_DESK_DOCK_HOME_CAPTURE is false <li>The device is in car mode but there's no CAR_DOCK app with METADATA_DOCK_HOME <li>The device is in desk mode but there's no DESK_DOCK app with METADATA_DOCK_HOME </ul>
 * @return
 */
Intent createHomeDockIntent(){
  Intent intent=null;
  if (mUiMode == Configuration.UI_MODE_TYPE_CAR) {
    if (ENABLE_CAR_DOCK_HOME_CAPTURE) {
      intent=mCarDockIntent;
    }
  }
 else   if (mUiMode == Configuration.UI_MODE_TYPE_DESK) {
    if (ENABLE_DESK_DOCK_HOME_CAPTURE) {
      intent=mDeskDockIntent;
    }
  }
  if (intent == null) {
    return null;
  }
  ActivityInfo ai=intent.resolveActivityInfo(mContext.getPackageManager(),PackageManager.GET_META_DATA);
  if (ai == null) {
    return null;
  }
  if (ai.metaData != null && ai.metaData.getBoolean(Intent.METADATA_DOCK_HOME)) {
    intent=new Intent(intent);
    intent.setClassName(ai.packageName,ai.name);
    return intent;
  }
  return null;
}
 

Example 29

From project dungbeetle, under directory /src/edu/stanford/mobisocial/dungbeetle/feed/objects/.

Source file: AppReferenceObj.java

  17 
vote

@Override public void handleDirectMessage(Context context,Contact from,JSONObject obj){
  String packageName=obj.optString(PACKAGE_NAME);
  String arg=obj.optString(ARG);
  Intent launch=new Intent();
  launch.setAction(Intent.ACTION_MAIN);
  launch.addCategory(Intent.CATEGORY_LAUNCHER);
  launch.putExtra(AppState.EXTRA_APPLICATION_ARGUMENT,arg);
  launch.putExtra("creator",false);
  launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  launch.setPackage(packageName);
  final PackageManager mgr=context.getPackageManager();
  List<ResolveInfo> resolved=mgr.queryIntentActivities(launch,0);
  if (resolved == null || resolved.size() == 0) {
    Toast.makeText(context,"Could not find application to handle invite",Toast.LENGTH_SHORT).show();
    return;
  }
  ActivityInfo info=resolved.get(0).activityInfo;
  launch.setComponent(new ComponentName(info.packageName,info.name));
  PendingIntent contentIntent=PendingIntent.getActivity(context,0,launch,PendingIntent.FLAG_CANCEL_CURRENT);
  (new PresenceAwareNotify(context)).notify("New Invitation","Invitation received from " + from.name,"Click to launch application.",contentIntent);
}
 

Example 30

From project filemanager, under directory /FileManager/src/org/openintents/filemanager/util/.

Source file: MenuUtils.java

  17 
vote

/** 
 * Call this to show the "More" dialog for the passed  {@link FileHolder}.
 * @param context Always useful, isn't it?
 */
private static void showMoreCommandsDialog(FileHolder holder,final Context context){
  final Uri data=Uri.fromFile(holder.getFile());
  final Intent intent=new Intent();
  intent.setDataAndType(data,holder.getMimeType());
  if (holder.getMimeType() != null) {
    PackageManager pm=context.getPackageManager();
    final List<ResolveInfo> lri=pm.queryIntentActivityOptions(new ComponentName(context,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 || context.checkCallingPermission(permission) == PackageManager.PERMISSION_GRANTED))       items.add(ri.loadLabel(pm));
 else       toRemove.add(ri);
    }
    for (    ResolveInfo ri : toRemove) {
      lri.remove(ri);
    }
    new AlertDialog.Builder(context).setTitle(holder.getName()).setIcon(holder.getIcon()).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));
        context.startActivity(rintent);
      }
    }
).create().show();
  }
}
 

Example 31

From project framework_base_policy, under directory /src/com/android/internal/policy/impl/.

Source file: PhoneWindowManager.java

  17 
vote

/** 
 * Return an Intent to launch the currently active dock app as home.  Returns null if the standard home should be launched, which is the case if any of the following is true: <ul> <li>The device is not in either car mode or desk mode <li>The device is in car mode but ENABLE_CAR_DOCK_HOME_CAPTURE is false <li>The device is in desk mode but ENABLE_DESK_DOCK_HOME_CAPTURE is false <li>The device is in car mode but there's no CAR_DOCK app with METADATA_DOCK_HOME <li>The device is in desk mode but there's no DESK_DOCK app with METADATA_DOCK_HOME </ul>
 * @return
 */
Intent createHomeDockIntent(){
  Intent intent=null;
  if (mUiMode == Configuration.UI_MODE_TYPE_CAR) {
    if (ENABLE_CAR_DOCK_HOME_CAPTURE) {
      intent=mCarDockIntent;
    }
  }
 else   if (mUiMode == Configuration.UI_MODE_TYPE_DESK) {
    if (ENABLE_DESK_DOCK_HOME_CAPTURE) {
      intent=mDeskDockIntent;
    }
  }
  if (intent == null) {
    return null;
  }
  ActivityInfo ai=intent.resolveActivityInfo(mContext.getPackageManager(),PackageManager.GET_META_DATA);
  if (ai == null) {
    return null;
  }
  if (ai.metaData != null && ai.metaData.getBoolean(Intent.METADATA_DOCK_HOME)) {
    intent=new Intent(intent);
    intent.setClassName(ai.packageName,ai.name);
    return intent;
  }
  return null;
}
 

Example 32

From project Game_3, under directory /android/src/playn/android/.

Source file: GameActivity.java

  17 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  context=getApplicationContext();
  AndroidGL20 gl20;
  if (isHoneycombOrLater() || !AndroidGL20Native.available) {
    gl20=new AndroidGL20();
  }
 else {
    gl20=new AndroidGL20Native();
  }
  viewLayout=new AndroidLayoutView(this);
  gameView=new GameViewGL(gl20,this,context);
  viewLayout.addView(gameView);
  if (isHoneycombOrLater()) {
    int flagHardwareAccelerated=0x1000000;
    getWindow().setFlags(flagHardwareAccelerated,flagHardwareAccelerated);
  }
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  LayoutParams params=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
  getWindow().setContentView(viewLayout,params);
  if (usePortraitOrientation()) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  }
 else {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  }
  try {
    ActivityInfo info=this.getPackageManager().getActivityInfo(new ComponentName(context,this.getPackageName() + "." + this.getLocalClassName()),0);
    if ((info.configChanges & REQUIRED_CONFIG_CHANGES) != REQUIRED_CONFIG_CHANGES) {
      new AlertDialog.Builder(this).setMessage("Unable to guarantee application will handle configuration changes. " + "Please add the following line to the Activity manifest: " + "      android:configChanges=\"keyboardHidden|orientation\"").show();
    }
  }
 catch (  NameNotFoundException e) {
    Log.w("playn","Cannot access game AndroidManifest.xml file.");
  }
}
 

Example 33

From project GreenDroid, under directory /GreenDroid/src/greendroid/app/.

Source file: GDActivity.java

  17 
vote

public void onPostContentChanged(){
  boolean titleSet=false;
  final Intent intent=getIntent();
  if (intent != null) {
    String title=intent.getStringExtra(ActionBarActivity.GD_ACTION_BAR_TITLE);
    if (title != null) {
      titleSet=true;
      setTitle(title);
    }
  }
  if (!titleSet) {
    try {
      final ActivityInfo activityInfo=getPackageManager().getActivityInfo(getComponentName(),0);
      if (activityInfo.labelRes != 0) {
        setTitle(activityInfo.labelRes);
      }
    }
 catch (    NameNotFoundException e) {
    }
  }
  final int visibility=intent.getIntExtra(ActionBarActivity.GD_ACTION_BAR_VISIBILITY,View.VISIBLE);
  getActionBar().setVisibility(visibility);
}
 

Example 34

From project GreenDroidQABar, under directory /src/greendroid/app/.

Source file: GDActivity.java

  17 
vote

public void onPostContentChanged(){
  boolean titleSet=false;
  final Intent intent=getIntent();
  if (intent != null) {
    String title=intent.getStringExtra(ActionBarActivity.GD_ACTION_BAR_TITLE);
    if (title != null) {
      titleSet=true;
      setTitle(title);
    }
  }
  if (!titleSet) {
    try {
      final ActivityInfo activityInfo=getPackageManager().getActivityInfo(getComponentName(),0);
      if (activityInfo.labelRes != 0) {
        setTitle(activityInfo.labelRes);
      }
    }
 catch (    NameNotFoundException e) {
    }
  }
  final int visibility=intent.getIntExtra(ActionBarActivity.GD_ACTION_BAR_VISIBILITY,View.VISIBLE);
  getActionBar().setVisibility(visibility);
}
 

Example 35

From project ListViewTipsAndTricks, under directory /src/com/cyrilmottier/android/listviewtipsandtricks/.

Source file: HomeListActivity.java

  17 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mAdapter=new ArrayAdapter<Tip>(this,android.R.layout.simple_list_item_1);
  final Intent mainIntent=new Intent(Intent.ACTION_MAIN,null);
  mainIntent.addCategory(CATEGORY_SAMPLE_CODE);
  final PackageManager pm=getPackageManager();
  List<ResolveInfo> resolveInfos=pm.queryIntentActivities(mainIntent,0);
  for (  ResolveInfo resolveInfo : resolveInfos) {
    final ActivityInfo ai=resolveInfo.activityInfo;
    String activityName=ai.name;
    int lastIndex=activityName.lastIndexOf(".");
    if (lastIndex > 0 && lastIndex < activityName.length()) {
      activityName=activityName.substring(lastIndex + 1,activityName.length());
    }
    final Intent intent=new Intent();
    intent.setClassName(ai.applicationInfo.packageName,ai.name);
    mAdapter.add(new Tip(activityName,intent));
  }
  setListAdapter(mAdapter);
}
 

Example 36

From project maven-android-plugin-samples, under directory /apidemos-android-10/application/src/main/java/com/example/android/apis/graphics/.

Source file: PurgeableBitmap.java

  17 
vote

private boolean detectIfPurgeableRequest(){
  PackageManager pm=getPackageManager();
  CharSequence labelSeq=null;
  try {
    ActivityInfo info=pm.getActivityInfo(this.getComponentName(),PackageManager.GET_META_DATA);
    labelSeq=info.loadLabel(pm);
  }
 catch (  NameNotFoundException e) {
    e.printStackTrace();
    return false;
  }
  String[] components=labelSeq.toString().split("/");
  if (components[components.length - 1].equals("Purgeable")) {
    return true;
  }
 else {
    return false;
  }
}
 

Example 37

From project Monetizing-Android-Demo-Project, under directory /src/com/adwhirl/.

Source file: AdWhirlLayout.java

  17 
vote

protected String getAdWhirlKey(Context context){
  final String packageName=context.getPackageName();
  final String activityName=context.getClass().getName();
  final PackageManager pm=context.getPackageManager();
  Bundle bundle=null;
  try {
    ActivityInfo activityInfo=pm.getActivityInfo(new ComponentName(packageName,activityName),PackageManager.GET_META_DATA);
    bundle=activityInfo.metaData;
    if (bundle != null) {
      return bundle.getString(AdWhirlLayout.ADWHIRL_KEY);
    }
  }
 catch (  NameNotFoundException exception) {
    return null;
  }
  try {
    ApplicationInfo appInfo=pm.getApplicationInfo(packageName,PackageManager.GET_META_DATA);
    bundle=appInfo.metaData;
    if (bundle != null) {
      return bundle.getString(AdWhirlLayout.ADWHIRL_KEY);
    }
  }
 catch (  NameNotFoundException exception) {
    return null;
  }
  return null;
}
 

Example 38

From project platform_frameworks_ex, under directory /carousel/test/src/com/android/carouseltest/.

Source file: TaskSwitcherActivity.java

  17 
vote

private void updateRecentTasks(){
  final PackageManager pm=getPackageManager();
  final ActivityManager am=(ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
  final List<ActivityManager.RecentTaskInfo> recentTasks=am.getRecentTasks(MAX_TASKS + 2,ActivityManager.RECENT_IGNORE_UNAVAILABLE);
  ActivityInfo homeInfo=new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME).resolveActivityInfo(pm,0);
  int numTasks=recentTasks.size();
  mActivityDescriptions.clear();
  for (int i=1, index=0; i < numTasks && (index < MAX_TASKS + 2); ++i) {
    final ActivityManager.RecentTaskInfo recentInfo=recentTasks.get(i);
    Intent intent=new Intent(recentInfo.baseIntent);
    if (recentInfo.origActivity != null) {
      intent.setComponent(recentInfo.origActivity);
    }
    if (homeInfo != null && homeInfo.packageName.equals(intent.getComponent().getPackageName()) && homeInfo.name.equals(intent.getComponent().getClassName())) {
      continue;
    }
    intent.setFlags((intent.getFlags() & ~Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED) | Intent.FLAG_ACTIVITY_NEW_TASK);
    final ResolveInfo resolveInfo=pm.resolveActivity(intent,0);
    if (resolveInfo != null) {
      final ActivityInfo info=resolveInfo.activityInfo;
      final String title=info.loadLabel(pm).toString();
      Drawable icon=info.loadIcon(pm);
      int id=recentInfo.id;
      if (id != -1 && title != null && title.length() > 0 && icon != null) {
        ActivityDescription item=new ActivityDescription(null,icon,title,null,id);
        item.intent=intent;
        mActivityDescriptions.add(item);
        Log.v(TAG,"Added item[" + index + "], id="+ item.id);
        ++index;
      }
 else {
        Log.v(TAG,"SKIPPING item " + id);
      }
    }
  }
}
 

Example 39

From project platform_frameworks_policies_base, under directory /phone/com/android/internal/policy/impl/.

Source file: PhoneWindowManager.java

  17 
vote

/** 
 * Return an Intent to launch the currently active dock as home.  Returns null if the standard home should be launched.
 * @return
 */
Intent createHomeDockIntent(){
  Intent intent;
  if (mUiMode == Configuration.UI_MODE_TYPE_CAR) {
    intent=mCarDockIntent;
  }
 else   if (mUiMode == Configuration.UI_MODE_TYPE_DESK) {
    intent=mDeskDockIntent;
  }
 else {
    return null;
  }
  ActivityInfo ai=intent.resolveActivityInfo(mContext.getPackageManager(),PackageManager.GET_META_DATA);
  if (ai == null) {
    return null;
  }
  if (ai.metaData != null && ai.metaData.getBoolean(Intent.METADATA_DOCK_HOME)) {
    intent=new Intent(intent);
    intent.setClassName(ai.packageName,ai.name);
    return intent;
  }
  return null;
}
 

Example 40

From project playn, under directory /android/src/playn/android/.

Source file: GameActivity.java

  17 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  context=getApplicationContext();
  AndroidGL20 gl20;
  if (isHoneycombOrLater() || !AndroidGL20Native.available) {
    gl20=new AndroidGL20();
  }
 else {
    gl20=new AndroidGL20Native();
  }
  viewLayout=new AndroidLayoutView(this);
  gameView=new GameViewGL(gl20,this,context);
  viewLayout.addView(gameView);
  if (isHoneycombOrLater()) {
    int flagHardwareAccelerated=0x1000000;
    getWindow().setFlags(flagHardwareAccelerated,flagHardwareAccelerated);
  }
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  LayoutParams params=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
  getWindow().setContentView(viewLayout,params);
  if (usePortraitOrientation()) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  }
 else {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  }
  try {
    ActivityInfo info=this.getPackageManager().getActivityInfo(new ComponentName(context,this.getPackageName() + "." + this.getLocalClassName()),0);
    if ((info.configChanges & REQUIRED_CONFIG_CHANGES) != REQUIRED_CONFIG_CHANGES) {
      new AlertDialog.Builder(this).setMessage("Unable to guarantee application will handle configuration changes. " + "Please add the following line to the Activity manifest: " + "      android:configChanges=\"keyboardHidden|orientation\"").show();
    }
  }
 catch (  NameNotFoundException e) {
    Log.w("playn","Cannot access game AndroidManifest.xml file.");
  }
}
 

Example 41

From project ratebeer-for-Android, under directory /JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarSupportImpl.java

  17 
vote

public void init(){
  mActionBar=(ActionBarView)getActivity().findViewById(R.id.action_bar);
  final MenuItemImpl homeMenuItem=getHomeMenuItem();
  final ActionBarView.Item homeItem=mActionBar.getHomeItem();
  final WatsonItemViewWrapper homeWrapper=new WatsonItemViewWrapper(homeItem);
  homeWrapper.initialize(homeMenuItem,MenuBuilder.TYPE_WATSON);
  homeMenuItem.setItemView(MenuBuilder.TYPE_WATSON,homeWrapper);
  final PackageManager pm=getActivity().getPackageManager();
  final ApplicationInfo appInfo=getActivity().getApplicationInfo();
  ActivityInfo actInfo=null;
  try {
    actInfo=pm.getActivityInfo(getActivity().getComponentName(),PackageManager.GET_ACTIVITIES);
  }
 catch (  NameNotFoundException e) {
  }
  if (mActionBar.getTitle() == null) {
    if ((actInfo != null) && (actInfo.labelRes != 0)) {
      mActionBar.setTitle(actInfo.labelRes);
    }
 else {
      mActionBar.setTitle(actInfo.loadLabel(pm));
    }
  }
  if (homeItem.getIcon() == null) {
    if ((actInfo != null) && (actInfo.icon != 0)) {
      homeItem.setIcon(actInfo.icon);
    }
 else {
      homeItem.setIcon(pm.getApplicationIcon(appInfo));
    }
  }
}
 

Example 42

From project ratebeerforandroid, under directory /JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarSupportImpl.java

  17 
vote

public void init(){
  mActionBar=(ActionBarView)getActivity().findViewById(R.id.action_bar);
  final MenuItemImpl homeMenuItem=getHomeMenuItem();
  final ActionBarView.Item homeItem=mActionBar.getHomeItem();
  final WatsonItemViewWrapper homeWrapper=new WatsonItemViewWrapper(homeItem);
  homeWrapper.initialize(homeMenuItem,MenuBuilder.TYPE_WATSON);
  homeMenuItem.setItemView(MenuBuilder.TYPE_WATSON,homeWrapper);
  final PackageManager pm=getActivity().getPackageManager();
  final ApplicationInfo appInfo=getActivity().getApplicationInfo();
  ActivityInfo actInfo=null;
  try {
    actInfo=pm.getActivityInfo(getActivity().getComponentName(),PackageManager.GET_ACTIVITIES);
  }
 catch (  NameNotFoundException e) {
  }
  if (mActionBar.getTitle() == null) {
    if ((actInfo != null) && (actInfo.labelRes != 0)) {
      mActionBar.setTitle(actInfo.labelRes);
    }
 else {
      mActionBar.setTitle(actInfo.loadLabel(pm));
    }
  }
  if (homeItem.getIcon() == null) {
    if ((actInfo != null) && (actInfo.icon != 0)) {
      homeItem.setIcon(actInfo.icon);
    }
 else {
      homeItem.setIcon(pm.getApplicationIcon(appInfo));
    }
  }
}
 

Example 43

From project android-marvin, under directory /marvin/src/main/java/de/akquinet/android/marvin/actions/.

Source file: ActivityAction.java

  15 
vote

public void flipOrientation(){
  actionPerformed();
  int currentOrientation=get().getRequestedOrientation();
  if (currentOrientation != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
    get().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  }
 else {
    get().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  }
}
 

Example 44

From project android_packages_apps_Gallery, under directory /src/com/android/camera/.

Source file: ImageGallery.java

  15 
vote

public void onImageClicked(int index){
  if (index < 0 || index >= mAllImages.getCount()) {
    return;
  }
  mSelectedIndex=index;
  mGvs.setSelectedIndex(index);
  IImage image=mAllImages.getImageAt(index);
  if (isInMultiSelectMode()) {
    toggleMultiSelected(image);
    return;
  }
  if (isPickIntent()) {
    launchCropperOrFinish(image);
  }
 else {
    Intent intent;
    if (image instanceof VideoObject) {
      intent=new Intent(Intent.ACTION_VIEW,image.fullSizeImageUri());
      intent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION,ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }
 else {
      intent=new Intent(this,ViewImage.class);
      intent.putExtra(ViewImage.KEY_IMAGE_LIST,mParam);
      intent.setData(image.fullSizeImageUri());
    }
    startActivity(intent);
  }
}
 

Example 45

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

Source file: MovieActivity.java

  15 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  requestWindowFeature(Window.FEATURE_ACTION_BAR);
  requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
  setContentView(R.layout.movie_view);
  View rootView=findViewById(R.id.movie_view_root);
  rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
  Intent intent=getIntent();
  initializeActionBar(intent);
  mFinishOnCompletion=intent.getBooleanExtra(MediaStore.EXTRA_FINISH_ON_COMPLETION,true);
  mTreatUpAsBack=intent.getBooleanExtra(KEY_TREAT_UP_AS_BACK,false);
  mPlayer=new MoviePlayer(rootView,this,intent.getData(),savedInstanceState,!mFinishOnCompletion){
    @Override public void onCompletion(){
      if (mFinishOnCompletion) {
        finish();
      }
    }
  }
;
  if (intent.hasExtra(MediaStore.EXTRA_SCREEN_ORIENTATION)) {
    int orientation=intent.getIntExtra(MediaStore.EXTRA_SCREEN_ORIENTATION,ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    if (orientation != getRequestedOrientation()) {
      setRequestedOrientation(orientation);
    }
  }
  Window win=getWindow();
  WindowManager.LayoutParams winParams=win.getAttributes();
  winParams.buttonBrightness=WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF;
  winParams.flags|=WindowManager.LayoutParams.FLAG_FULLSCREEN;
  win.setAttributes(winParams);
  win.setBackgroundDrawable(null);
}
 

Example 46

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

Source file: AddOnsFactory.java

  15 
vote

protected boolean isPackageContainAnAddon(Context context,String packageNameSchemePart) throws NameNotFoundException {
  PackageInfo newPackage=context.getPackageManager().getPackageInfo(packageNameSchemePart,PackageManager.GET_RECEIVERS + PackageManager.GET_META_DATA);
  if (newPackage.receivers != null) {
    ActivityInfo[] receivers=newPackage.receivers;
    for (    ActivityInfo aReceiver : receivers) {
      if (aReceiver == null || aReceiver.applicationInfo == null || !aReceiver.enabled || !aReceiver.applicationInfo.enabled)       continue;
      final XmlPullParser xml=aReceiver.loadXmlMetaData(context.getPackageManager(),RECEIVER_META_DATA);
      if (xml != null) {
        return true;
      }
    }
  }
  return false;
}
 

Example 47

From project appdriver, under directory /android/src/com/google/android/testing/nativedriver/server/.

Source file: AndroidNativeDriver.java

  15 
vote

@Override public void rotate(ScreenOrientation orientation){
  int activityOrientation;
  if (orientation == ScreenOrientation.LANDSCAPE) {
    activityOrientation=ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
  }
 else {
    activityOrientation=ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
  }
  context.getOnMainSyncRunner().run(doRotate(activityOrientation));
}
 

Example 48

From project BBC-News-Reader, under directory /src/com/digitallizard/bbcnewsreader/.

Source file: CategoryActivity.java

  15 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  this.setContentView(R.layout.category_activity);
  if (getResources().getBoolean(R.bool.screen_xlarge)) {
    currentDisplayMode=DISPLAY_MODE_TABLET_LANDSCAPE;
  }
 else {
    currentDisplayMode=DISPLAY_MODE_HANDSET;
  }
  if (currentDisplayMode == DISPLAY_MODE_TABLET_LANDSCAPE) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    CategoryFragment fragment=(CategoryFragment)getSupportFragmentManager().findFragmentById(R.id.categoryFragment);
    fragment.displayCategory(getIntent().getStringExtra(EXTRA_CATEGORY_TITLE));
  }
  if (currentDisplayMode == DISPLAY_MODE_HANDSET) {
    getSupportActionBar().setTitle(getIntent().getStringExtra(EXTRA_CATEGORY_TITLE));
    CategoryFragment fragment=(CategoryFragment)getSupportFragmentManager().findFragmentById(R.id.categoryFragment);
    fragment.displayCategory(getIntent().getStringExtra(EXTRA_CATEGORY_TITLE));
  }
}
 

Example 49

From project BibleQuote-for-Android, under directory /src/com/BibleQuote/activity/.

Source file: ReaderActivity.java

  15 
vote

@Override public void onConfigurationChanged(Configuration newConfig){
  if (PreferenceHelper.restoreStateBoolean("DisableAutoScreenRotation")) {
    super.onConfigurationChanged(newConfig);
    this.setRequestedOrientation(Surface.ROTATION_0);
  }
 else {
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
    super.onConfigurationChanged(newConfig);
  }
}
 

Example 50

From project Cafe, under directory /testrunner/src/com/baidu/cafe/local/.

Source file: LocalLib.java

  15 
vote

/** 
 * setRequestedOrientation
 * @param orientation : local.setRequestedOrientation(CafeTestCase.SCREEN_ORIENTATION_PORTRAIT ); local.setRequestedOrientation(CafeTestCase.SCREEN_ORIENTATION_LANDSCAPE );
 */
public void setRequestedOrientation(int orientation){
  if (orientation == CafeTestCase.SCREEN_ORIENTATION_LANDSCAPE) {
    this.mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  }
 else   if (orientation == CafeTestCase.SCREEN_ORIENTATION_PORTRAIT) {
    this.mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  }
}
 

Example 51

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

Source file: StageActivity.java

  15 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  stageListener=new StageListener();
  stageDialog=new StageDialog(this,stageListener,R.style.stage_dialog);
  this.calculateScreenSizes();
  initialize(stageListener,true);
}
 

Example 52

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

Source file: CCDirector.java

  15 
vote

public void setDeviceOrientation(int orientation){
  if (deviceOrientation_ != orientation) {
    deviceOrientation_=orientation;
switch (deviceOrientation_) {
case kCCDeviceOrientationPortrait:
      theApp.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    break;
case kCCDeviceOrientationLandscapeLeft:
  theApp.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
break;
default :
Log.w(LOG_TAG,"Director: Unknown device orientation");
break;
}
}
}
 

Example 53

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

Source file: ConsoleActivity.java

  15 
vote

/** 
 */
private void configureOrientation(){
  String rotateDefault;
  if (getResources().getConfiguration().keyboard == Configuration.KEYBOARD_NOKEYS)   rotateDefault=PreferenceConstants.ROTATION_PORTRAIT;
 else   rotateDefault=PreferenceConstants.ROTATION_LANDSCAPE;
  String rotate=prefs.getString(PreferenceConstants.ROTATION,rotateDefault);
  if (PreferenceConstants.ROTATION_DEFAULT.equals(rotate))   rotate=rotateDefault;
  if (PreferenceConstants.ROTATION_LANDSCAPE.equals(rotate)) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    forcedOrientation=true;
  }
 else   if (PreferenceConstants.ROTATION_PORTRAIT.equals(rotate)) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    forcedOrientation=true;
  }
 else {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    forcedOrientation=false;
  }
}
 

Example 54

From project daily-money, under directory /dailymoney/src/com/bottleworks/commons/util/.

Source file: GUIs.java

  15 
vote

static public void lockOrientation(Activity activity){
switch (activity.getResources().getConfiguration().orientation) {
case Configuration.ORIENTATION_PORTRAIT:
    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  break;
case Configuration.ORIENTATION_LANDSCAPE:
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
break;
}
}
 

Example 55

From project droid-comic-viewer, under directory /src/net/robotmedia/acv/ui/.

Source file: ComicViewerActivity.java

  15 
vote

private void rotate(){
  int orientation=getResources().getConfiguration().orientation;
  int requestedOrientation=ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
switch (orientation) {
case Configuration.ORIENTATION_LANDSCAPE:
    requestedOrientation=ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
  orientation=Configuration.ORIENTATION_PORTRAIT;
break;
case Configuration.ORIENTATION_PORTRAIT:
requestedOrientation=ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
orientation=Configuration.ORIENTATION_LANDSCAPE;
break;
}
Editor editor=preferences.edit();
editor.putInt(Constants.ORIENTATION_KEY,orientation);
editor.commit();
requestedRotation=true;
setRequestedOrientation(requestedOrientation);
}
 

Example 56

From project eoit, under directory /EOIT/src/fr/eoit/activity/.

Source file: ParameterActivity.java

  15 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  setContentView(R.layout.parameters);
  setProgressBarIndeterminate(true);
  setProgressBarIndeterminateVisibility(true);
  if (Parameters.keyId <= 0) {
    Toast.makeText(this,R.string.parameters_not_set,Toast.LENGTH_LONG).show();
  }
  skillLoadingProgress=(ProgressBar)findViewById(R.id.SKILL_LIST_LOADING);
  receiver=new SkillUpdaterBroadcastReceiver(skillLoadingProgress);
  refreshCharacterSpinner();
  String[] dataColumns={Item.COLUMN_NAME_NAME,Parameter.COLUMN_NAME_PARAM_VALUE};
  int[] viewIDs={R.id.ITEM_NAME,R.id.SKILL_LEVEL_ICON};
  adapter=new SimpleCursorAdapter(this,R.layout.skillrow,null,dataColumns,viewIDs,SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
  adapter.setViewBinder(new SkillListViewBinder());
  skillListView=(ListView)findViewById(R.id.SKILLS_LIST);
  skillListView.setVisibility(View.GONE);
  skillListView.setAdapter(adapter);
  findViewById(R.id.location_management_layout).setOnClickListener(new GenericIntentLauncherOnClickListener(fr.eoit.db.bean.Station.CONTENT_URI,LocationManagementActivity.class,getApplicationContext()));
  findViewById(R.id.MINING_REGION_LAYOUT).setOnClickListener(new ParametersMiningSpaceOnClickListener(this));
  findViewById(R.id.MINING_REGION_SEC_LAYOUT).setOnClickListener(new ParametersMiningSecOnClickListener(this));
  ((CheckBox)findViewById(R.id.MINING_SWITCH)).setChecked(Parameters.isMiningActive);
  ((CheckBox)findViewById(R.id.MINING_SWITCH)).setOnCheckedChangeListener(new OnCheckedChangeListener(){
    @Override public void onCheckedChanged(    CompoundButton buttonView,    boolean isChecked){
      Parameters.isMiningActive=isChecked;
    }
  }
);
  initOrRestart();
}
 

Example 57

From project fanfoudroid, under directory /src/com/ch_linghu/fanfoudroid/.

Source file: PreferencesActivity.java

  15 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (TwitterApplication.mPref.getBoolean(Preferences.FORCE_SCREEN_ORIENTATION_PORTRAIT,false)) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  }
  setResult(RESULT_OK);
  addPreferencesFromResource(R.xml.preferences);
}
 

Example 58

From project FBReaderJ, under directory /src/org/geometerplus/android/fbreader/.

Source file: SetOrientationAction.java

  15 
vote

static void setOrientation(Activity activity,String optionValue){
  int orientation=ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
  if (ZLibrary.SCREEN_ORIENTATION_SENSOR.equals(optionValue)) {
    orientation=ActivityInfo.SCREEN_ORIENTATION_SENSOR;
  }
 else   if (ZLibrary.SCREEN_ORIENTATION_PORTRAIT.equals(optionValue)) {
    orientation=ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
  }
 else   if (ZLibrary.SCREEN_ORIENTATION_LANDSCAPE.equals(optionValue)) {
    orientation=ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
  }
 else   if (ZLibrary.SCREEN_ORIENTATION_REVERSE_PORTRAIT.equals(optionValue)) {
    orientation=9;
  }
 else   if (ZLibrary.SCREEN_ORIENTATION_REVERSE_LANDSCAPE.equals(optionValue)) {
    orientation=8;
  }
  activity.setRequestedOrientation(orientation);
}
 

Example 59

From project finch, under directory /libs/JakeWharton-ActionBarSherlock-2eabf25/samples/demos/src/com/actionbarsherlock/sample/demos/.

Source file: StaticAttachment.java

  15 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  setTheme(SampleList.THEME);
  super.onCreate(savedInstanceState);
  mSherlock.setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);
  mSherlock.setContentView(R.layout.text);
  ((TextView)findViewById(R.id.text)).setText(R.string.static_attach_content);
}
 

Example 60

From project flexymind-alpha, under directory /src/com/flexymind/alpha/.

Source file: Settings.java

  15 
vote

public void onToggleClicked(View view){
  if (((ToggleButton)view).isChecked()) {
    orientation=ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
  }
 else {
    orientation=ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
  }
}
 

Example 61

From project GCM-Demo, under directory /gcm/gcm-client/src/com/google/android/gcm/.

Source file: GCMRegistrar.java

  15 
vote

/** 
 * Checks that the application manifest is properly configured. <p> A proper configuration means: <ol> <li>It creates a custom permission called {@code PACKAGE_NAME.permission.C2D_MESSAGE}. <li>It defines at least one  {@link BroadcastReceiver} with category{@code PACKAGE_NAME}. <li>The  {@link BroadcastReceiver}(s) uses the {@value GCMConstants#PERMISSION_GCM_INTENTS} permission.<li>The  {@link BroadcastReceiver}(s) handles the 3 GCM intents ( {@value GCMConstants#INTENT_FROM_GCM_MESSAGE}, {@value GCMConstants#INTENT_FROM_GCM_REGISTRATION_CALLBACK}, and  {@value GCMConstants#INTENT_FROM_GCM_LIBRARY_RETRY}). </ol> ...where  {@code PACKAGE_NAME} is the application package.<p> This method should be used during development time to verify that the manifest is properly set up, but it doesn't need to be called once the application is deployed to the users' devices.
 * @param context application context.
 * @throws IllegalStateException if any of the conditions above is not met.
 */
public static void checkManifest(Context context){
  PackageManager packageManager=context.getPackageManager();
  String packageName=context.getPackageName();
  String permissionName=packageName + ".permission.C2D_MESSAGE";
  try {
    packageManager.getPermissionInfo(permissionName,PackageManager.GET_PERMISSIONS);
  }
 catch (  NameNotFoundException e) {
    throw new IllegalStateException("Application does not define permission " + permissionName);
  }
  PackageInfo receiversInfo;
  try {
    receiversInfo=packageManager.getPackageInfo(packageName,PackageManager.GET_RECEIVERS);
  }
 catch (  NameNotFoundException e) {
    throw new IllegalStateException("Could not get receivers for package " + packageName);
  }
  ActivityInfo[] receivers=receiversInfo.receivers;
  if (receivers == null || receivers.length == 0) {
    throw new IllegalStateException("No receiver for package " + packageName);
  }
  if (Log.isLoggable(TAG,Log.VERBOSE)) {
    Log.v(TAG,"number of receivers for " + packageName + ": "+ receivers.length);
  }
  Set<String> allowedReceivers=new HashSet<String>();
  for (  ActivityInfo receiver : receivers) {
    if (GCMConstants.PERMISSION_GCM_INTENTS.equals(receiver.permission)) {
      allowedReceivers.add(receiver.name);
    }
  }
  if (allowedReceivers.isEmpty()) {
    throw new IllegalStateException("No receiver allowed to receive " + GCMConstants.PERMISSION_GCM_INTENTS);
  }
  checkReceiver(context,allowedReceivers,GCMConstants.INTENT_FROM_GCM_REGISTRATION_CALLBACK);
  checkReceiver(context,allowedReceivers,GCMConstants.INTENT_FROM_GCM_MESSAGE);
}
 

Example 62

From project HarleyDroid, under directory /src/org/harleydroid/.

Source file: HarleyDroid.java

  15 
vote

@Override public void onStart(){
  if (D)   Log.d(TAG,"onStart()");
  super.onStart();
  mInterfaceType=mPrefs.getString("interfacetype",null);
  mBluetoothID=mPrefs.getString("bluetoothid",null);
  mAutoConnect=mAutoConnect && mPrefs.getBoolean("autoconnect",false);
  mAutoReconnect=mPrefs.getBoolean("autoreconnect",false);
  mReconnectDelay=mPrefs.getString("reconnectdelay","30");
  if (mPrefs.getString("orientation","auto").equals("auto"))   mOrientation=ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
 else   if (mPrefs.getString("orientation","auto").equals("portrait")) {
    mOrientation=ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
  }
 else   if (mPrefs.getString("orientation","auto").equals("landscape")) {
    mOrientation=ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
  }
  this.setRequestedOrientation(mOrientation);
  mLogging=false;
  if (mPrefs.getBoolean("logging",false)) {
    if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()))     Toast.makeText(this,R.string.toast_errorlogging,Toast.LENGTH_LONG).show();
 else     mLogging=true;
  }
  mGPS=mPrefs.getBoolean("gps",false);
  mLogRaw=mPrefs.getBoolean("lograw",false);
  if (mPrefs.getBoolean("screenon",false))   getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  if (mPrefs.getString("unit","metric").equals("metric"))   mUnitMetric=true;
 else   mUnitMetric=false;
  bindService(new Intent(this,HarleyDroidService.class),this,0);
  if (mAutoConnect && mBluetoothID != null && mService == null) {
    mAutoConnect=false;
    startHDS();
  }
}
 

Example 63

From project hiofenigma-android, under directory /gestures/src/hiof/enigma/android/gestures/.

Source file: GesturesDemoActivity.java

  15 
vote

/** 
 * Here we use the Display object we created to check what orientation the screen is in. If it is Landscape, we put it in Portrait and vice versa.
 */
private void toggleOrientation(){
switch (display.getRotation()) {
case Surface.ROTATION_0:
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  break;
case Surface.ROTATION_180:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
break;
case Surface.ROTATION_270:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
break;
case Surface.ROTATION_90:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
break;
}
}
 

Example 64

From project Jota-Text-Editor, under directory /src/jp/sblo/pandora/jota/.

Source file: Main.java

  15 
vote

void applyBootSetting(){
  mBootSettings=SettingsActivity.readBootSettings(this);
  if (mBootSettings.hideTitleBar) {
    setTheme(R.style.Theme_NoTitleBar);
  }
  if (mBootSettings.screenOrientation.equals(SettingsActivity.ORI_AUTO)) {
  }
 else   if (mBootSettings.screenOrientation.equals(SettingsActivity.ORI_PORTRAIT)) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  }
 else   if (mBootSettings.screenOrientation.equals(SettingsActivity.ORI_LANDSCAPE)) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  }
}
 

Example 65

From project k-9, under directory /src/com/fsck/k9/activity/.

Source file: MessageCompose.java

  15 
vote

@Override public void onPause(){
  super.onPause();
  MessagingController.getInstance(getApplication()).removeListener(mListener);
  if (!mIgnoreOnPause && (getChangingConfigurations() & ActivityInfo.CONFIG_ORIENTATION) == 0) {
    saveIfNeeded();
  }
}
 

Example 66

From project LigiAndroidCommons, under directory /src/org/ligi/android/common/activitys/.

Source file: ActivityOrientationLocker.java

  15 
vote

public static void disableRotation(Activity activity){
switch (activity.getResources().getConfiguration().orientation) {
case Configuration.ORIENTATION_PORTRAIT:
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.FROYO) {
      activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
 else {
      int rotation=activity.getWindowManager().getDefaultDisplay().getRotation();
      if (rotation == android.view.Surface.ROTATION_90 || rotation == android.view.Surface.ROTATION_180) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
      }
 else {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
      }
    }
  break;
case Configuration.ORIENTATION_LANDSCAPE:
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.FROYO) {
  activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
 else {
  int rotation=activity.getWindowManager().getDefaultDisplay().getRotation();
  if (rotation == android.view.Surface.ROTATION_0 || rotation == android.view.Surface.ROTATION_90) {
    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  }
 else {
    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
  }
}
break;
}
}
 

Example 67

From project mediautilities, under directory /src/ac/robinson/util/.

Source file: UIUtilities.java

  15 
vote

public static int getNaturalScreenOrientation(WindowManager windowManager){
  Display display=windowManager.getDefaultDisplay();
  int width=0;
  int height=0;
switch (display.getRotation()) {
case Surface.ROTATION_0:
case Surface.ROTATION_180:
    width=display.getWidth();
  height=display.getHeight();
break;
case Surface.ROTATION_90:
case Surface.ROTATION_270:
width=display.getHeight();
height=display.getWidth();
break;
default :
break;
}
if (width > height) {
return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
}
return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
}
 

Example 68

From project Memo, under directory /src/com/ngarside/memo/.

Source file: MemoActivity.java

  15 
vote

public void onFinish(){
  lockToOrientation=tempOrientation == 1 || tempOrientation == 2;
  if (tempOrientation == 0) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
  }
 else   if (tempOrientation == 1) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  }
 else {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  }
}
 

Example 69

From project mixare, under directory /plugins/mixare-arena-splashscreen-plugin/src/org/mixare/plugin/arenasplash/.

Source file: ArenaSplashActivity.java

  15 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.main);
  exitRunnable=new Runnable(){
    public void run(){
      exitSplash();
    }
  }
;
  exitHandler=new Handler();
  exitHandler.postDelayed(exitRunnable,SPLASHTIME);
}
 

Example 70

From project MobiPerf, under directory /android/src/com/mobiperf/speedometer/.

Source file: SplashScreenActivity.java

  15 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.splash_screen);
  this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
  TextView version=(TextView)findViewById(R.id.splash_version);
  try {
    PackageInfo pInfo=getPackageManager().getPackageInfo(getPackageName(),0);
    version.setText(pInfo.versionName);
  }
 catch (  NameNotFoundException e) {
  }
  new Handler().postDelayed(new Runnable(){
    @Override public void run(){
      Intent intent=new Intent(SpeedometerApp.class.getName());
      intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      SplashScreenActivity.this.getApplication().startActivity(intent);
      SplashScreenActivity.this.finish();
    }
  }
,Config.SPLASH_SCREEN_DURATION_MSEC);
}
 

Example 71

From project packages_apps_Camera_1, under directory /src/com/android/camera/.

Source file: ActivityBase.java

  15 
vote

@Override public void onCreate(Bundle icicle){
  if (Util.isTabletUI()) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  }
 else {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  }
  super.onCreate(icicle);
}
 

Example 72

From project packages_apps_Camera_2, under directory /src/com/android/camera/.

Source file: ActivityBase.java

  15 
vote

@Override public void onCreate(Bundle icicle){
  if (Util.isTabletUI()) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  }
 else {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  }
  super.onCreate(icicle);
}
 

Example 73

From project Pixelesque, under directory /src/com/rj/pixelesque/.

Source file: PixelArtEditor.java

  15 
vote

public void figureOutOrientation(){
  if (isHorizontal()) {
    setRequestedOrientation(6);
  }
 else {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  }
}
 

Example 74

From project platform_packages_apps_Gallery, under directory /src/com/android/camera/.

Source file: ImageGallery.java

  15 
vote

public void onImageClicked(int index){
  if (index < 0 || index >= mAllImages.getCount()) {
    return;
  }
  mSelectedIndex=index;
  mGvs.setSelectedIndex(index);
  IImage image=mAllImages.getImageAt(index);
  if (isInMultiSelectMode()) {
    toggleMultiSelected(image);
    return;
  }
  if (isPickIntent()) {
    launchCropperOrFinish(image);
  }
 else {
    Intent intent;
    if (image instanceof VideoObject) {
      intent=new Intent(Intent.ACTION_VIEW,image.fullSizeImageUri());
      intent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION,ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }
 else {
      intent=new Intent(this,ViewImage.class);
      intent.putExtra(ViewImage.KEY_IMAGE_LIST,mParam);
      intent.setData(image.fullSizeImageUri());
    }
    startActivity(intent);
  }
}
 

Example 75

From project platform_packages_apps_Gallery2_1, under directory /src/com/android/gallery3d/app/.

Source file: MovieActivity.java

  15 
vote

@Override public void onCreate(Bundle icicle){
  super.onCreate(icicle);
  setContentView(R.layout.movie_view);
  View rootView=findViewById(R.id.root);
  Intent intent=getIntent();
  mFinishOnCompletion=intent.getBooleanExtra(MediaStore.EXTRA_FINISH_ON_COMPLETION,true);
  mControl=new MovieViewControl(rootView,this,intent.getData()){
    @Override public void onCompletion(){
      if (mFinishOnCompletion) {
        finish();
      }
 else {
        super.onCompletion();
        if (super.toQuit()) {
          finish();
        }
      }
    }
  }
;
  if (intent.hasExtra(MediaStore.EXTRA_SCREEN_ORIENTATION)) {
    int orientation=intent.getIntExtra(MediaStore.EXTRA_SCREEN_ORIENTATION,ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    if (orientation != getRequestedOrientation()) {
      setRequestedOrientation(orientation);
    }
  }
  Window win=getWindow();
  WindowManager.LayoutParams winParams=win.getAttributes();
  winParams.buttonBrightness=WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF;
  win.setAttributes(winParams);
}
 

Example 76

From project Rhybudd, under directory /src/net/networksaremadeofstring/rhybudd/.

Source file: RhybuddDock.java

  15 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  setContentView(R.layout.dock);
  actionbar=getSupportActionBar();
  actionbar.setDisplayHomeAsUpEnabled(true);
  actionbar.setHomeButtonEnabled(true);
  actionbar.setTitle("Rhybudd Dock");
  rhybuddCache=new RhybuddDatabase(this);
  settings=PreferenceManager.getDefaultSharedPreferences(this);
  list=(ListView)findViewById(R.id.ZenossEventsList);
  ConfigureHandler();
  GaugeHandler.sendEmptyMessage(1);
  GaugeHandler.sendEmptyMessage(2);
  Refresh();
}
 

Example 77

From project Sage-Mobile-Calc, under directory /src/org/connectbot/.

Source file: ConsoleActivity.java

  15 
vote

/** 
 */
private void configureOrientation(){
  String rotateDefault;
  if (getResources().getConfiguration().keyboard == Configuration.KEYBOARD_NOKEYS)   rotateDefault=PreferenceConstants.ROTATION_PORTRAIT;
 else   rotateDefault=PreferenceConstants.ROTATION_LANDSCAPE;
  String rotate=prefs.getString(PreferenceConstants.ROTATION,rotateDefault);
  if (PreferenceConstants.ROTATION_DEFAULT.equals(rotate))   rotate=rotateDefault;
  if (PreferenceConstants.ROTATION_LANDSCAPE.equals(rotate)) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    forcedOrientation=true;
  }
 else   if (PreferenceConstants.ROTATION_PORTRAIT.equals(rotate)) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    forcedOrientation=true;
  }
 else {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    forcedOrientation=false;
  }
}
 

Example 78

From project SamyGo-Android-Remote, under directory /src/de/quist/app/samyGoRemote/.

Source file: Remote.java

  15 
vote

private void showInputDialog(){
  setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
  AlertDialog.Builder builder=new AlertDialog.Builder(this);
  builder.setTitle(R.string.text_input_title);
  EditText edit=new EditText(this);
  edit.addTextChangedListener(new TextWatcher(){
    public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
    }
    public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    public void afterTextChanged(    Editable s){
      TextSender sender=(TextSender)mSender;
      try {
        sender.sendText(s.toString());
      }
 catch (      IOException e) {
      }
catch (      InterruptedException e) {
      }
    }
  }
);
  builder.setView(edit);
  AlertDialog d=builder.create();
  d.setOnDismissListener(new OnDismissListener(){
    public void onDismiss(    DialogInterface dialog){
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
  }
);
  d.show();
}
 

Example 79

From project SASAbus, under directory /src/it/sasabz/android/sasabus/classes/.

Source file: FileRetriever.java

  15 
vote

/** 
 * This constructor takes an activity, a dbZipFile to store the  downloaded Zip file, a dbFile to store the unzipped database and at least a md5File to save the downloaded md5File
 * @param activity is the actual activity
 * @param dbZIPFile is the file to save the downloaded zip file
 * @param dbFile is the file to save the unzipped db file
 * @param md5File is the file to save the downloaded md5 file
 */
public FileRetriever(CheckDatabaseActivity activity,String filename){
  super();
  this.filename=filename;
  this.activity=activity;
  this.res=activity.getResources();
  PowerManager pm=(PowerManager)this.activity.getSystemService(Context.POWER_SERVICE);
  wakeLock=pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE,TAG);
  originalRequestedOrientation=activity.getRequestedOrientation();
  activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
  wakeLock.acquire();
}