Java Code Examples for android.content.ComponentName

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 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/widget/.

Source file: ActivityChooserModel.java

  32 
vote

/** 
 * Sets the default activity. The default activity is set by adding a historical record with weight high enough that this activity will become the highest ranked. Such a strategy guarantees that the default will eventually change if not used. Also the weight of the record for setting a default is inflated with a constant amount to guarantee that it will stay as default for awhile.
 * @param index The index of the activity to set as default.
 */
public void setDefaultActivity(int index){
  ActivityResolveInfo newDefaultActivity=mActivites.get(index);
  ActivityResolveInfo oldDefaultActivity=mActivites.get(0);
  final float weight;
  if (oldDefaultActivity != null) {
    weight=oldDefaultActivity.weight - newDefaultActivity.weight + DEFAULT_ACTIVITY_INFLATION;
  }
 else {
    weight=DEFAULT_HISTORICAL_RECORD_WEIGHT;
  }
  ComponentName defaultName=new ComponentName(newDefaultActivity.resolveInfo.activityInfo.packageName,newDefaultActivity.resolveInfo.activityInfo.name);
  HistoricalRecord historicalRecord=new HistoricalRecord(defaultName,System.currentTimeMillis(),weight);
  addHisoricalRecord(historicalRecord);
}
 

Example 2

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

Source file: ActivityChooserModel.java

  32 
vote

/** 
 * Sets the default activity. The default activity is set by adding a historical record with weight high enough that this activity will become the highest ranked. Such a strategy guarantees that the default will eventually change if not used. Also the weight of the record for setting a default is inflated with a constant amount to guarantee that it will stay as default for awhile.
 * @param index The index of the activity to set as default.
 */
public void setDefaultActivity(int index){
  ActivityResolveInfo newDefaultActivity=mActivites.get(index);
  ActivityResolveInfo oldDefaultActivity=mActivites.get(0);
  final float weight;
  if (oldDefaultActivity != null) {
    weight=oldDefaultActivity.weight - newDefaultActivity.weight + DEFAULT_ACTIVITY_INFLATION;
  }
 else {
    weight=DEFAULT_HISTORICAL_RECORD_WEIGHT;
  }
  ComponentName defaultName=new ComponentName(newDefaultActivity.resolveInfo.activityInfo.packageName,newDefaultActivity.resolveInfo.activityInfo.name);
  HistoricalRecord historicalRecord=new HistoricalRecord(defaultName,System.currentTimeMillis(),weight);
  addHisoricalRecord(historicalRecord);
}
 

Example 3

From project AlarmApp-Android, under directory /src/com/google/android/c2dm/.

Source file: C2DMessaging.java

  32 
vote

/** 
 * Initiate c2d messaging registration for the current application
 */
public static void register(Context context,String senderId){
  Intent registrationIntent=new Intent(REQUEST_REGISTRATION_INTENT);
  registrationIntent.setPackage(GSF_PACKAGE);
  registrationIntent.putExtra(EXTRA_APPLICATION_PENDING_INTENT,PendingIntent.getBroadcast(context,0,new Intent(),0));
  registrationIntent.putExtra(EXTRA_SENDER,senderId);
  ComponentName name=context.startService(registrationIntent);
  LogEx.info("Started service" + name);
}
 

Example 4

From project Amantech, under directory /Android/action_bar_sherlock/src/com/actionbarsherlock/widget/.

Source file: ActivityChooserModel.java

  32 
vote

/** 
 * Sets the default activity. The default activity is set by adding a historical record with weight high enough that this activity will become the highest ranked. Such a strategy guarantees that the default will eventually change if not used. Also the weight of the record for setting a default is inflated with a constant amount to guarantee that it will stay as default for awhile.
 * @param index The index of the activity to set as default.
 */
public void setDefaultActivity(int index){
  ActivityResolveInfo newDefaultActivity=mActivites.get(index);
  ActivityResolveInfo oldDefaultActivity=mActivites.get(0);
  final float weight;
  if (oldDefaultActivity != null) {
    weight=oldDefaultActivity.weight - newDefaultActivity.weight + DEFAULT_ACTIVITY_INFLATION;
  }
 else {
    weight=DEFAULT_HISTORICAL_RECORD_WEIGHT;
  }
  ComponentName defaultName=new ComponentName(newDefaultActivity.resolveInfo.activityInfo.packageName,newDefaultActivity.resolveInfo.activityInfo.name);
  HistoricalRecord historicalRecord=new HistoricalRecord(defaultName,System.currentTimeMillis(),weight);
  addHisoricalRecord(historicalRecord);
}
 

Example 5

From project andlytics, under directory /actionbarsherlock/src/com/actionbarsherlock/widget/.

Source file: ActivityChooserModel.java

  32 
vote

/** 
 * Sets the default activity. The default activity is set by adding a historical record with weight high enough that this activity will become the highest ranked. Such a strategy guarantees that the default will eventually change if not used. Also the weight of the record for setting a default is inflated with a constant amount to guarantee that it will stay as default for awhile.
 * @param index The index of the activity to set as default.
 */
public void setDefaultActivity(int index){
  ActivityResolveInfo newDefaultActivity=mActivites.get(index);
  ActivityResolveInfo oldDefaultActivity=mActivites.get(0);
  final float weight;
  if (oldDefaultActivity != null) {
    weight=oldDefaultActivity.weight - newDefaultActivity.weight + DEFAULT_ACTIVITY_INFLATION;
  }
 else {
    weight=DEFAULT_HISTORICAL_RECORD_WEIGHT;
  }
  ComponentName defaultName=new ComponentName(newDefaultActivity.resolveInfo.activityInfo.packageName,newDefaultActivity.resolveInfo.activityInfo.name);
  HistoricalRecord historicalRecord=new HistoricalRecord(defaultName,System.currentTimeMillis(),weight);
  addHisoricalRecord(historicalRecord);
}
 

Example 6

From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/widget/.

Source file: WidgetProvider.java

  32 
vote

@Override public void onReceive(android.content.Context context,Intent intent){
  super.onReceive(context,intent);
  String action=intent.getAction();
  if (TaskProvider.cUpdateIntent.equals(action) || ProjectProvider.cUpdateIntent.equals(action) || ContextProvider.cUpdateIntent.equals(action)) {
    AppWidgetManager appWidgetManager=AppWidgetManager.getInstance(context);
    ComponentName thisWidget=new ComponentName(context,WidgetProvider.class);
    int[] appWidgetIds=appWidgetManager.getAppWidgetIds(thisWidget);
    if (appWidgetIds != null && appWidgetIds.length > 0) {
      this.onUpdate(context,appWidgetManager,appWidgetIds);
    }
  }
}
 

Example 7

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

Source file: ActivityChooserModel.java

  32 
vote

/** 
 * Sets the default activity. The default activity is set by adding a historical record with weight high enough that this activity will become the highest ranked. Such a strategy guarantees that the default will eventually change if not used. Also the weight of the record for setting a default is inflated with a constant amount to guarantee that it will stay as default for awhile.
 * @param index The index of the activity to set as default.
 */
public void setDefaultActivity(int index){
  ActivityResolveInfo newDefaultActivity=mActivites.get(index);
  ActivityResolveInfo oldDefaultActivity=mActivites.get(0);
  final float weight;
  if (oldDefaultActivity != null) {
    weight=oldDefaultActivity.weight - newDefaultActivity.weight + DEFAULT_ACTIVITY_INFLATION;
  }
 else {
    weight=DEFAULT_HISTORICAL_RECORD_WEIGHT;
  }
  ComponentName defaultName=new ComponentName(newDefaultActivity.resolveInfo.activityInfo.packageName,newDefaultActivity.resolveInfo.activityInfo.name);
  HistoricalRecord historicalRecord=new HistoricalRecord(defaultName,System.currentTimeMillis(),weight);
  addHisoricalRecord(historicalRecord);
}
 

Example 8

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

Source file: GalleryUtils.java

  32 
vote

public static boolean isCameraAvailable(Context context){
  if (sCameraAvailableInitialized)   return sCameraAvailable;
  PackageManager pm=context.getPackageManager();
  ComponentName name=new ComponentName(context,CAMERA_LAUNCHER_NAME);
  int state=pm.getComponentEnabledSetting(name);
  sCameraAvailableInitialized=true;
  sCameraAvailable=(state == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) || (state == PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
  return sCameraAvailable;
}
 

Example 9

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

Source file: Util.java

  32 
vote

public static void openMaps(Context context,double latitude,double longitude){
  try {
    String url=String.format("http://maps.google.com/maps?f=q&q=(%s,%s)",latitude,longitude);
    ComponentName compName=new ComponentName(MAPS_PACKAGE_NAME,MAPS_CLASS_NAME);
    Intent mapsIntent=new Intent(Intent.ACTION_VIEW,Uri.parse(url)).setComponent(compName);
    context.startActivity(mapsIntent);
  }
 catch (  ActivityNotFoundException e) {
    Log.e(TAG,"GMM activity not found!",e);
    String url=String.format("geo:%s,%s",latitude,longitude);
    Intent mapsIntent=new Intent(Intent.ACTION_VIEW,Uri.parse(url));
    context.startActivity(mapsIntent);
  }
}
 

Example 10

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

Source file: AppsCorpus.java

  32 
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 11

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

Source file: AnkiDroidWidget.java

  32 
vote

@Override public void onStart(Intent intent,int startId){
  Log.i(AnkiDroidApp.TAG,"OnStart");
  RemoteViews updateViews=buildUpdate(this);
  ComponentName thisWidget=new ComponentName(this,AnkiDroidWidget.class);
  AppWidgetManager manager=AppWidgetManager.getInstance(this);
  manager.updateAppWidget(thisWidget,updateViews);
}
 

Example 12

From project Apertiurm-Androind-app-devlopment, under directory /ApertiumAndroid/src/org/apertium/android/widget/.

Source file: WidgetProvider.java

  32 
vote

@Override public void onUpdate(Context context,AppWidgetManager appWidgetManager,int[] appWidgetIds){
  ComponentName thisWidget=new ComponentName(context,WidgetProvider.class);
  int[] allWidgetIds=appWidgetManager.getAppWidgetIds(thisWidget);
  for (  int widgetId : allWidgetIds) {
    Log.i("Widgets",widgetId + "");
    initView(context,widgetId);
    fillView(context);
    addClickListner(context,widgetId);
    appWidgetManager.updateAppWidget(widgetId,remoteViews);
  }
}
 

Example 13

From project BF3-Battlelog, under directory /src/com/ninetwozero/battlelog/widgets/.

Source file: BattlelogAppWidgetProvider.java

  32 
vote

@Override public void onReceive(Context context,Intent intent){
  super.onReceive(context,intent);
  AppWidgetManager appWidgetManager=AppWidgetManager.getInstance(context);
  ComponentName thisAppWidget=new ComponentName(context,BattlelogAppWidgetProvider.class);
  int[] appWidgetIds=appWidgetManager.getAppWidgetIds(thisAppWidget);
  onUpdate(context,appWidgetManager,appWidgetIds);
}
 

Example 14

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

Source file: ActivityChooserModel.java

  32 
vote

/** 
 * Sets the default activity. The default activity is set by adding a historical record with weight high enough that this activity will become the highest ranked. Such a strategy guarantees that the default will eventually change if not used. Also the weight of the record for setting a default is inflated with a constant amount to guarantee that it will stay as default for awhile.
 * @param index The index of the activity to set as default.
 */
public void setDefaultActivity(int index){
  ActivityResolveInfo newDefaultActivity=mActivites.get(index);
  ActivityResolveInfo oldDefaultActivity=mActivites.get(0);
  final float weight;
  if (oldDefaultActivity != null) {
    weight=oldDefaultActivity.weight - newDefaultActivity.weight + DEFAULT_ACTIVITY_INFLATION;
  }
 else {
    weight=DEFAULT_HISTORICAL_RECORD_WEIGHT;
  }
  ComponentName defaultName=new ComponentName(newDefaultActivity.resolveInfo.activityInfo.packageName,newDefaultActivity.resolveInfo.activityInfo.name);
  HistoricalRecord historicalRecord=new HistoricalRecord(defaultName,System.currentTimeMillis(),weight);
  addHisoricalRecord(historicalRecord);
}
 

Example 15

From project conference-mobile-app, under directory /android-app/src/novoda/droidcon/homewidget/.

Source file: CountdownWidget.java

  32 
vote

/** 
 * Updates the counter
 */
private static void updateScore(final Context context){
  final RemoteViews views=new RemoteViews(context.getPackageName(),R.layout.widget_countdown);
  int remainingSec=(int)Math.max(0,(UIUtils.CONFERENCE_START_MILLIS - System.currentTimeMillis()) / 1000);
  final int secs=remainingSec % 86400;
  final int days=remainingSec / 86400;
  final String str=context.getResources().getQuantityString(R.plurals.widget_countdown_title,days,days,formatRemainingTime(secs));
  views.setTextViewText(R.id.widget_title,str);
  final Intent appIntent=new Intent(context,HomeActivity.class);
  PendingIntent appStartPI=PendingIntent.getActivity(context,0,appIntent,0);
  views.setOnClickPendingIntent(R.id.countdown_widget,appStartPI);
  final ComponentName widget=new ComponentName(context,CountdownWidget.class);
  AppWidgetManager.getInstance(context).updateAppWidget(widget,views);
}
 

Example 16

From project cornerstone, under directory /frameworks/base/core/java/android/app/.

Source file: ActivityManagerNative.java

  32 
vote

public ComponentName getCallingActivity(IBinder token) throws RemoteException {
  Parcel data=Parcel.obtain();
  Parcel reply=Parcel.obtain();
  data.writeInterfaceToken(IActivityManager.descriptor);
  data.writeStrongBinder(token);
  mRemote.transact(GET_CALLING_ACTIVITY_TRANSACTION,data,reply,0);
  reply.readException();
  ComponentName res=ComponentName.readFromParcel(reply);
  data.recycle();
  reply.recycle();
  return res;
}
 

Example 17

From project Android-Battery-Widget, under directory /src/com/em/batterywidget/.

Source file: BatteryUpdateService.java

  31 
vote

@Override public void onStart(Intent intent,int id){
  if (mBatteryReceiver == null) {
    registerNewReceiver();
  }
  AppWidgetManager manager=AppWidgetManager.getInstance(this);
  RemoteViews widgetView=getWidgetRemoteView();
  if (this.getResources().getBoolean(R.bool.lowVersion)) {
    manager.updateAppWidget(new ComponentName(this,BatteryWidget.class),widgetView);
  }
 else {
    manager.updateAppWidget(new ComponentName(this,BatteryWidget_HC.class),widgetView);
  }
}
 

Example 18

From project android-pedometer, under directory /src/name/bagi/levente/pedometer/.

Source file: StepService.java

  31 
vote

/** 
 * Show a notification while this service is running.
 */
private void showNotification(){
  CharSequence text=getText(R.string.app_name);
  Notification notification=new Notification(R.drawable.ic_notification,null,System.currentTimeMillis());
  notification.flags=Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
  Intent pedometerIntent=new Intent();
  pedometerIntent.setComponent(new ComponentName(this,Pedometer.class));
  pedometerIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  PendingIntent contentIntent=PendingIntent.getActivity(this,0,pedometerIntent,0);
  notification.setLatestEventInfo(this,text,getText(R.string.notification_subtitle),contentIntent);
  mNM.notify(R.string.app_name,notification);
}
 

Example 19

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

Source file: SmsPopupUtils.java

  31 
vote

/** 
 * This function will see if the most recent activity was the system messaging app so we can suppress the popup as the user is likely already viewing messages or composing a new message
 */
public static final boolean inMessagingApp(Context context){
  final String PACKAGE_NAME="com.android.mms";
  final String CONVO_CLASS_NAME="com.android.mms.ui.ConversationList";
  ActivityManager mAM=(ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
  List<RunningTaskInfo> mRunningTaskList=mAM.getRunningTasks(1);
  Iterator<RunningTaskInfo> mIterator=mRunningTaskList.iterator();
  if (mIterator.hasNext()) {
    RunningTaskInfo mRunningTask=mIterator.next();
    if (mRunningTask != null) {
      ComponentName runningTaskComponent=mRunningTask.baseActivity;
      if (PACKAGE_NAME.equals(runningTaskComponent.getPackageName()) && CONVO_CLASS_NAME.equals(runningTaskComponent.getClassName())) {
        return true;
      }
    }
  }
  return false;
}
 

Example 20

From project androidtracks, under directory /src/org/sfcta/cycletracks/.

Source file: MainInput.java

  31 
vote

private void buildAlertMessageNoGps(){
  final AlertDialog.Builder builder=new AlertDialog.Builder(this);
  builder.setMessage("Your phone's GPS is disabled. CycleTracks needs GPS to determine your location.\n\nGo to System Settings now to enable GPS?").setCancelable(false).setPositiveButton("GPS Settings...",new DialogInterface.OnClickListener(){
    public void onClick(    final DialogInterface dialog,    final int id){
      final ComponentName toLaunch=new ComponentName("com.android.settings","com.android.settings.SecuritySettings");
      final Intent intent=new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
      intent.addCategory(Intent.CATEGORY_LAUNCHER);
      intent.setComponent(toLaunch);
      intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      startActivityForResult(intent,0);
    }
  }
).setNegativeButton("Cancel",new DialogInterface.OnClickListener(){
    public void onClick(    final DialogInterface dialog,    final int id){
      dialog.cancel();
    }
  }
);
  final AlertDialog alert=builder.create();
  alert.show();
}
 

Example 21

From project Android_1, under directory /PropagatedIntents/src/com/example/android/notepad/.

Source file: NotesList.java

  31 
vote

@Override public boolean onCreateOptionsMenu(Menu menu){
  super.onCreateOptionsMenu(menu);
  menu.add(0,MENU_ITEM_INSERT,0,R.string.menu_insert).setShortcut('3','a').setIcon(android.R.drawable.ic_menu_add);
  Intent intent=new Intent(null,getIntent().getData());
  intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
  menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE,0,0,new ComponentName(this,NotesList.class),null,intent,0,null);
  return true;
}
 

Example 22

From project android_7, under directory /src/org/immopoly/android/helper/.

Source file: LocationHelper.java

  31 
vote

public static void requestLocationSettings(final Context context){
  AlertDialog.Builder builder=new AlertDialog.Builder(context);
  builder.setTitle(R.string.allow_localization_title);
  builder.setMessage(R.string.allow_localization_message);
  builder.setCancelable(true).setNegativeButton(R.string.button_cancel,new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int id){
    }
  }
);
  final Intent locationSettingsIntent=new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
  final ComponentName toLaunch=new ComponentName("com.android.settings","com.android.settings.SecuritySettings");
  locationSettingsIntent.addCategory(Intent.CATEGORY_LAUNCHER);
  locationSettingsIntent.setComponent(toLaunch);
  locationSettingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  final Intent generellSettingsIntent=new Intent(Settings.ACTION_SETTINGS);
  builder.setPositiveButton("Einstellungen",new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int id){
      if (context.getPackageManager().resolveActivity(locationSettingsIntent,PackageManager.MATCH_DEFAULT_ONLY) != null) {
        context.startActivity(locationSettingsIntent);
      }
 else       if (context.getPackageManager().resolveActivity(generellSettingsIntent,PackageManager.MATCH_DEFAULT_ONLY) != null) {
        context.startActivity(generellSettingsIntent);
      }
 else {
        Toast.makeText(context,context.getString(R.string.allow_localization_message_manuel),Toast.LENGTH_LONG).show();
      }
    }
  }
);
  AlertDialog alert=builder.create();
  alert.show();
}
 

Example 23

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

Source file: RunningServiceDetails.java

  31 
vote

@Override protected Dialog onCreateDialog(int id,Bundle args){
switch (id) {
case DIALOG_CONFIRM_STOP:
{
      final ComponentName comp=(ComponentName)args.getParcelable("comp");
      if (activeDetailForService(comp) == null) {
        return null;
      }
      return new AlertDialog.Builder(this).setTitle(getString(R.string.runningservicedetails_stop_dlg_title)).setIcon(android.R.drawable.ic_dialog_alert).setMessage(getString(R.string.runningservicedetails_stop_dlg_text)).setPositiveButton(R.string.dlg_ok,new DialogInterface.OnClickListener(){
        public void onClick(        DialogInterface dialog,        int which){
          ActiveDetail ad=activeDetailForService(comp);
          if (ad != null) {
            ad.stopActiveService(true);
          }
        }
      }
).setNegativeButton(R.string.dlg_cancel,null).create();
    }
default :
  return super.onCreateDialog(id,args);
}
}
 

Example 24

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

Source file: EulaOrNewVersion.java

  31 
vote

private static void startForwardActivity(Activity activity,Class launchClass){
  Intent forwardIntent=activity.getIntent();
  Intent i=new Intent(activity,launchClass);
  ComponentName ci=activity.getComponentName();
  if (debug)   Log.d(TAG,"Local package name: " + ci.getPackageName());
  if (debug)   Log.d(TAG,"Local class name: " + ci.getClassName());
  i.putExtra(EXTRA_LAUNCH_ACTIVITY_PACKAGE,ci.getPackageName());
  i.putExtra(EXTRA_LAUNCH_ACTIVITY_CLASS,ci.getClassName());
  if (forwardIntent != null) {
    i.putExtra(EXTRA_LAUNCH_ACTIVITY_INTENT,forwardIntent);
  }
  i.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
  activity.startActivity(i);
  activity.finish();
}
 

Example 25

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

Source file: NfcDispatcher.java

  31 
vote

static boolean isComponentEnabled(PackageManager pm,ResolveInfo info){
  boolean enabled=false;
  ComponentName compname=new ComponentName(info.activityInfo.packageName,info.activityInfo.name);
  try {
    if (pm.getActivityInfo(compname,0) != null) {
      enabled=true;
    }
  }
 catch (  PackageManager.NameNotFoundException e) {
    enabled=false;
  }
  if (!enabled) {
    Log.d(TAG,"Component not enabled: " + compname);
  }
  return enabled;
}
 

Example 26

From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/util/.

Source file: Util.java

  31 
vote

public static void goHome(Context context){
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(context);
  Intent intent;
  if (prefs.getBoolean(Preferences.GHOST_MODE,false)) {
    intent=new Intent(context,HomeActivity.class);
  }
 else {
    intent=new Intent();
    intent.setComponent(new ComponentName("com.noshufou.android.su","com.noshufou.android.su.Su"));
  }
  intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  context.startActivity(intent);
}
 

Example 27

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

Source file: ApplicationInfo.java

  31 
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 28

From project andstatus, under directory /src/org/andstatus/app/.

Source file: TimelineActivity.java

  31 
vote

@Override public boolean onCreateOptionsMenu(Menu menu){
  super.onCreateOptionsMenu(menu);
  MenuInflater inflater=getMenuInflater();
  inflater.inflate(R.menu.timeline,menu);
  Intent intent=new Intent(null,getIntent().getData());
  intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
  menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE,0,0,new ComponentName(this,TimelineActivity.class),null,intent,0,null);
  return true;
}
 

Example 29

From project andtweet, under directory /src/com/xorcode/andtweet/.

Source file: TimelineActivity.java

  31 
vote

@Override public boolean onCreateOptionsMenu(Menu menu){
  super.onCreateOptionsMenu(menu);
  MenuInflater inflater=getMenuInflater();
  inflater.inflate(R.menu.timeline,menu);
  Intent intent=new Intent(null,getIntent().getData());
  intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
  menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE,0,0,new ComponentName(this,TweetListActivity.class),null,intent,0,null);
  return true;
}
 

Example 30

From project AnySoftKeyboard, under directory /src/com/menny/android/anysoftkeyboard/.

Source file: AnyApplication.java

  31 
vote

public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,String key){
  ((ConfigurationImpl)msConfig).onSharedPreferenceChanged(sharedPreferences,key);
  if (key.equals(getString(R.string.settings_key_show_settings_app))) {
    PackageManager pm=getPackageManager();
    boolean showApp=sharedPreferences.getBoolean(key,getResources().getBoolean(R.bool.settings_default_show_settings_app));
    pm.setComponentEnabledSetting(new ComponentName(getApplicationContext(),com.menny.android.anysoftkeyboard.LauncherSettingsActivity.class),showApp ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,PackageManager.DONT_KILL_APP);
  }
}
 

Example 31

From project apps-for-android, under directory /CLiCkin2DaBeaT/src/com/google/clickin2dabeat/.

Source file: C2B.java

  31 
vote

private void displayNoFilesMessage(){
  Builder noFilesMessage=new Builder(this);
  String titleText=getString(R.string.NO_STAGES_FOUND);
  noFilesMessage.setTitle(titleText);
  String message=getString(R.string.NO_STAGES_INFO);
  noFilesMessage.setMessage(message);
  noFilesMessage.setPositiveButton(getString(R.string.SHUT_UP),new OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      loadHardCodedRickroll();
    }
  }
);
  final Activity self=this;
  noFilesMessage.setNeutralButton(getString(R.string.ILL_GET_STAGES),new OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      Intent i=new Intent();
      ComponentName comp=new ComponentName("com.android.browser","com.android.browser.BrowserActivity");
      i.setComponent(comp);
      i.setAction("android.intent.action.VIEW");
      i.addCategory("android.intent.category.BROWSABLE");
      Uri uri=Uri.parse("http://groups.google.com/group/clickin-2-da-beat/files");
      i.setData(uri);
      self.startActivity(i);
      finish();
    }
  }
);
  noFilesMessage.setNegativeButton(getString(R.string.QUIT),new OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      finish();
    }
  }
);
  noFilesMessage.setCancelable(false);
  noFilesMessage.show();
}
 

Example 32

From project callmeter, under directory /src/de/ub0r/android/callmeter/widget/.

Source file: StatsAppWidgetProvider.java

  31 
vote

/** 
 * Update all running widgets.
 * @param context {@link Context}
 */
public static void updateWidgets(final Context context){
  Log.d(TAG,"updateWidgets()");
  final AppWidgetManager appWidgetManager=AppWidgetManager.getInstance(context);
  final int[] appWidgetIds=appWidgetManager.getAppWidgetIds(new ComponentName(context,StatsAppWidgetProvider.class));
  updateWidgets(context,appWidgetManager,appWidgetIds);
}
 

Example 33

From project CHMI, under directory /src/org/kaldax/app/chmi/.

Source file: CHMIWidgetProvider.java

  31 
vote

@Override public void onReceive(Context context,Intent intent){
  PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
  WakeLock wl=pm.newWakeLock(PowerManager.FULL_WAKE_LOCK,"Refresh chmi widget");
  try {
    wl.acquire();
    super.onReceive(context,intent);
    if (MY_WIDGET_UPDATE.equals(intent.getAction())) {
      Bundle extras=intent.getExtras();
      if (extras != null) {
        AppWidgetManager appWidgetManager=AppWidgetManager.getInstance(context);
        ComponentName thisAppWidget=new ComponentName(context.getPackageName(),CHMIWidgetProvider.class.getName());
        int[] appWidgetIds=appWidgetManager.getAppWidgetIds(thisAppWidget);
        onUpdate(context,appWidgetManager,appWidgetIds);
      }
    }
  }
  finally {
    if (wl != null) {
      wl.release();
    }
  }
}
 

Example 34

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

Source file: ActionMenu.java

  30 
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 35

From project Absolute-Android-RSS, under directory /src/com/AA/Recievers/.

Source file: AAWidgetProvider.java

  30 
vote

/** 
 * Sends out an update to the widget with the given title and description
 * @param context - Context that gives us access to some system operations
 * @param title - Text that will go in the title block
 * @param description - Text that goes in the description block
 */
private static void updateWidget(Context context,String title,String description){
  AppWidgetManager widgetManager=AppWidgetManager.getInstance(context);
  Intent activity=new Intent();
  activity.setClass(context,AAMain.class);
  PendingIntent pendingIntent=PendingIntent.getActivity(context,0,activity,0);
  RemoteViews rv_main=new RemoteViews(context.getPackageName(),R.layout.widget_layout);
  rv_main.setOnClickPendingIntent(R.id.iv_widget_bottom,pendingIntent);
  rv_main.setOnClickPendingIntent(R.id.iv_widget_top,pendingIntent);
  rv_main.setTextViewText(R.id.tv_title,title);
  rv_main.setTextViewText(R.id.tv_description,description);
  int[] widgetIds=widgetManager.getAppWidgetIds(new ComponentName(context,AAWidgetProvider.class));
  for (int i=0; i < widgetIds.length; i++) {
    rv_main.setImageViewResource(R.id.iv_widget_top,context.getSharedPreferences("settings",0).getInt("" + widgetIds[i],R.drawable.widget_layout_top));
    widgetManager.updateAppWidget(widgetIds[i],rv_main);
  }
}
 

Example 36

From project adg-android, under directory /src/com/analysedesgeeks/android/os_service/.

Source file: PodcastPlaybackService.java

  30 
vote

@Override public void onCreate(){
  super.onCreate();
  mAudioManager=(AudioManager)getSystemService(Context.AUDIO_SERVICE);
  mAudioManager.registerMediaButtonEventReceiver(new ComponentName(getPackageName(),MediaButtonIntentReceiver.class.getName()));
  mPlayer=new MultiPlayer();
  mPlayer.setHandler(mMediaplayerHandler);
  final IntentFilter commandFilter=new IntentFilter();
  commandFilter.addAction(SERVICECMD);
  commandFilter.addAction(TOGGLEPAUSE_ACTION);
  commandFilter.addAction(PAUSE_ACTION);
  registerReceiver(mIntentReceiver,commandFilter);
  final PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,this.getClass().getName());
  mWakeLock.setReferenceCounted(false);
  final Message msg=mDelayedStopHandler.obtainMessage();
  mDelayedStopHandler.sendMessageDelayed(msg,IDLE_DELAY);
}
 

Example 37

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

Source file: NotificationMgr.java

  30 
vote

/** 
 * Display the network selection "no service" notification
 * @param operator is the numeric operator number
 */
private void showNetworkSelection(String operator){
  if (DBG)   log("showNetworkSelection(" + operator + ")...");
  String titleText=mContext.getString(R.string.notification_network_selection_title);
  String expandedText=mContext.getString(R.string.notification_network_selection_text,operator);
  Notification notification=new Notification();
  notification.icon=android.R.drawable.stat_sys_warning;
  notification.when=0;
  notification.flags=Notification.FLAG_ONGOING_EVENT;
  notification.tickerText=null;
  Intent intent=new Intent(Intent.ACTION_MAIN);
  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
  intent.setComponent(new ComponentName("com.android.phone","com.android.phone.NetworkSetting"));
  PendingIntent pi=PendingIntent.getActivity(mContext,0,intent,0);
  notification.setLatestEventInfo(mContext,titleText,expandedText,pi);
  mNotificationMgr.notify(SELECTED_OPERATOR_FAIL_NOTIFICATION,notification);
}
 

Example 38

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

Source file: RecordUtils.java

  30 
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 39

From project Birthday-widget, under directory /Birthday/src/main/java/cz/krtinec/birthday/.

Source file: BirthdayWidget.java

  30 
vote

@Override public void onReceive(Context ctx,Intent intent){
  super.onReceive(ctx,intent);
  if (Utils.WIDGET_UPDATE.equals(intent.getAction())) {
    Log.d("Birthday","Service started...");
    AppWidgetManager manager=AppWidgetManager.getInstance(ctx);
    List<Event> list=BirthdayProvider.getInstance().upcomingBirthday(ctx);
    int max=getListSize();
    if (max > list.size()) {
      max=list.size();
    }
    list=list.subList(0,max);
    RemoteViews views=new RemoteViews("cz.krtinec.birthday",getLayout());
    updateViews(ctx,views,list);
    Intent i=new Intent(ctx.getApplicationContext(),Birthday.class);
    views.setOnClickPendingIntent(R.id.layout,PendingIntent.getActivity(ctx,WIDGET_CODE,i,PendingIntent.FLAG_UPDATE_CURRENT));
    list=null;
    manager.updateAppWidget(new ComponentName(ctx,getWidgetClass()),views);
  }
}
 

Example 40

From project box-android-sdk, under directory /OneCloudAppToApp/src/com/box/onecloud/android/.

Source file: BoxOneCloudReceiver.java

  30 
vote

@Override public void onReceive(final Context context,final Intent intent){
  OneCloudData oneCloudData=null;
  if (intent.getParcelableExtra(EXTRA_ONE_CLOUD) != null) {
    oneCloudData=(OneCloudData)intent.getParcelableExtra(EXTRA_ONE_CLOUD);
    oneCloudData.sendHandshake(context);
  }
  if (intent.getAction().equals(ACTION_BOX_EDIT_FILE)) {
    onEditFileRequested(context,oneCloudData);
  }
 else   if (intent.getAction().equals(ACTION_BOX_CREATE_FILE)) {
    onCreateFileRequested(context,oneCloudData);
  }
 else   if (intent.getAction().equals(ACTION_BOX_VIEW_FILE)) {
    onViewFileRequested(context,oneCloudData);
  }
 else   if (intent.getAction().equals(ACTION_BOX_LAUNCH)) {
    onLaunchRequested(context,oneCloudData);
  }
 else   if (intent.getAction().equals("com.android.vending.INSTALL_REFERRER")) {
    final String referrer=intent.getStringExtra("referrer");
    if (referrer == null) {
      return;
    }
    if (!referrer.toLowerCase().contains("box")) {
      return;
    }
    Intent broadcast=new Intent(ACTION_BOX_INSTALL_REFERRED);
    broadcast.setComponent(new ComponentName(BOX_PACKAGE_NAME,BOX_RECEIVER_CLASS_NAME));
    broadcast.putExtra(EXTRA_REFERRER,referrer);
    broadcast.putExtra(EXTRA_PACKAGE_NAME,context.getPackageName());
    context.sendBroadcast(broadcast);
  }
}
 

Example 41

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

Source file: CostumeActivity.java

  30 
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 42

From project agit, under directory /agit/src/main/java/com/madgag/agit/ssh/.

Source file: AndroidAuthAgentProvider.java

  29 
vote

private void bindSshAgentTo(Context context){
  Intent intent=new Intent("org.openintents.ssh.BIND_SSH_AGENT_SERVICE");
  intent.setComponent(preferredAuthAgentComponentNameProvider.get());
  context.bindService(intent,new ServiceConnection(){
    public void onServiceDisconnected(    ComponentName name){
      Log.i(TAG,"onServiceDisconnected() : Lost " + authAgent);
      authAgent=null;
    }
    public void onServiceConnected(    ComponentName name,    IBinder binder){
      Log.i(TAG,"onServiceConnected() : componentName=" + name + " binder="+ binder);
      authAgent=AndroidAuthAgent.Stub.asInterface(binder);
      signalAuthAgentBound();
    }
  }
,BIND_AUTO_CREATE);
  Log.i(TAG,"made request using context " + context + " to bind to the SSH_AGENT_SERVICE");
}
 

Example 43

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

Source file: BillingService.java

  29 
vote

/** 
 * This is called when we are connected to the MarketBillingService. This runs in the main UI thread.
 */
@Override public void onServiceConnected(ComponentName name,IBinder service){
  if (Consts.DEBUG) {
    Log.d(TAG,"Billing service connected");
  }
  mService=IMarketBillingService.Stub.asInterface(service);
  runPendingRequests();
}
 

Example 44

From project aksunai, under directory /src/org/androidnerds/app/aksunai/ui/.

Source file: ChatActivity.java

  29 
vote

public void onServiceConnected(ComponentName name,IBinder service){
  mManager=((ChatManager.ChatBinder)service).getService();
  if (getIntent().hasExtra("id")) {
    Bundle extras=getIntent().getExtras();
    ServerDetail details=new ServerDetail(ChatActivity.this,extras.getLong("id"));
    boolean found=false;
synchronized (mManager.mConnections) {
      for (      Server s : mManager.mConnections.values()) {
        if (s.mName.equals(details.mName)) {
          found=true;
        }
      }
    }
    if (!found) {
      Log.d(AppConstants.CHAT_TAG,"need to establish a connection.");
      mManager.openServerConnection(ChatActivity.this,details);
    }
  }
  if (AppConstants.DEBUG) {
    Log.d(AppConstants.CHAT_TAG,"Connected to the service.");
  }
  runOnUiThread(updateChatViews);
}
 

Example 45

From project android-bankdroid, under directory /src/com/liato/bankdroid/liveview/.

Source file: LiveViewService.java

  29 
vote

@Override public void onServiceConnected(final ComponentName className,IBinder service){
  Log.d(PluginConstants.LOG_TAG,"Enter LiveViewService.ServiceConnection.onServiceConnected.");
  mLiveView=IPluginServiceV1.Stub.asInterface(service);
  LiveViewCallback lvCallback=new LiveViewCallback();
  try {
    if (mLiveView != null) {
      mPluginId=mLiveView.register(lvCallback,mMenuIcon,mPluginName,false,getPackageName());
      Log.d(PluginConstants.LOG_TAG,"Plugin registered with id: " + mPluginId);
    }
  }
 catch (  RemoteException re) {
    Log.e(PluginConstants.LOG_TAG,"Failed to install plugin. Stop self.");
    stopSelf();
  }
  Log.d(PluginConstants.LOG_TAG,"Plugin registered. mPluginId: " + mPluginId);
}
 

Example 46

From project android-client_1, under directory /src/com/buddycloud/view/.

Source file: BCActivity.java

  29 
vote

/** 
 * Bind to the buddycloud service, if not yet bound or dead.
 */
protected final synchronized void bindBCService(){
  Intent serviceIntent=new Intent(IBuddycloudService.class.getCanonicalName());
  startService(serviceIntent);
  if (connection == null) {
    connection=new ServiceConnection(){
      public void onServiceDisconnected(      ComponentName name){
      }
      public void onServiceConnected(      ComponentName name,      IBinder binder){
        service=IBuddycloudService.Stub.asInterface(binder);
        onBuddycloudServiceBound();
      }
    }
;
  }
  if (service != null) {
    if (service.asBinder().isBinderAlive()) {
      return;
    }
 else {
      service=null;
    }
  }
  bindService(new Intent(IBuddycloudService.class.getName()),connection,Context.BIND_AUTO_CREATE);
}
 

Example 47

From project android-donations-lib, under directory /org_donations/src/org/donations/google/.

Source file: BillingService.java

  29 
vote

/** 
 * This is called when we are connected to the MarketBillingService. This runs in the main UI thread.
 */
public void onServiceConnected(ComponentName name,IBinder service){
  if (Consts.DEBUG) {
    Log.d(TAG,"Billing service connected");
  }
  mService=IMarketBillingService.Stub.asInterface(service);
  runPendingRequests();
}
 

Example 48

From project Android-Terminal-Emulator, under directory /src/jackpal/androidterm/.

Source file: Term.java

  29 
vote

public void onServiceConnected(ComponentName className,IBinder service){
  Log.i(TermDebug.LOG_TAG,"Bound to TermService");
  TermService.TSBinder binder=(TermService.TSBinder)service;
  mTermService=binder.getService();
  if (mPendingPathBroadcasts <= 0) {
    populateViewFlipper();
    populateWindowList();
  }
}
 

Example 49

From project android-vpn-settings, under directory /src/com/android/settings/vpn/.

Source file: AuthenticationActor.java

  29 
vote

private void connect(final String username,final String password){
  mVpnManager.startVpnService();
  ServiceConnection c=new ServiceConnection(){
    public void onServiceConnected(    ComponentName className,    IBinder service){
      try {
        boolean success=IVpnService.Stub.asInterface(service).connect(mProfile,username,password);
        if (!success) {
          Log.d(TAG,"~~~~~~ connect() failed!");
        }
 else {
          Log.d(TAG,"~~~~~~ connect() succeeded!");
        }
      }
 catch (      Throwable e) {
        Log.e(TAG,"connect()",e);
        broadcastConnectivity(VpnState.IDLE,VpnManager.VPN_ERROR_CONNECTION_FAILED);
      }
 finally {
        mContext.unbindService(this);
      }
    }
    public void onServiceDisconnected(    ComponentName className){
      checkStatus();
    }
  }
;
  if (!bindService(c)) {
    broadcastConnectivity(VpnState.IDLE,VpnManager.VPN_ERROR_CONNECTION_FAILED);
  }
}
 

Example 50

From project AndroidLab, under directory /src/src/de/tubs/ibr/android/ldap/core/activities/.

Source file: EditContactActivity.java

  29 
vote

@Override public void onServiceConnected(ComponentName name,IBinder service){
  mBinder=(LDAPService.LDAPBinder)service;
  mBinder.setActivityCallBackHandler(messageHandler);
  mBinder.setRunnable(new ShowDirResultsRunnable(mContext));
  for (  Account acc : AccountManager.get(mContext).getAccounts()) {
    if (acc.name.equals(mSelectedAccount.getName()) && acc.type.equals(mSelectedAccount.getType())) {
      instance=new ServerInstance(AccountManager.get(mContext),acc);
      break;
    }
  }
  mBinder.searchDirs(instance);
}
 

Example 51

From project android_5, under directory /src/aarddict/android/.

Source file: BaseDictionaryActivity.java

  29 
vote

public void onServiceDisconnected(ComponentName className){
  Log.d(TAG,"Service disconnected: " + dictionaryService);
  dictionaryService=null;
  Toast.makeText(BaseDictionaryActivity.this,"Dictionary service disconnected, quitting...",Toast.LENGTH_LONG).show();
  finish();
}
 

Example 52

From project ANE-In-App-Purchase, under directory /NativeAndroid/src/com/freshplanet/inapppurchase/.

Source file: BillingService.java

  29 
vote

/** 
 * This is called when we are connected to the MarketBillingService. This runs in the main UI thread.
 */
public void onServiceConnected(ComponentName name,IBinder service){
  if (Consts.DEBUG) {
    Log.d(TAG,"Billing service connected");
  }
  mService=IMarketBillingService.Stub.asInterface(service);
  runPendingRequests();
}
 

Example 53

From project AsmackService, under directory /src/com/googlecode/asmack/sync/.

Source file: LoginTestThread.java

  29 
vote

/** 
 * Bind to the xmpp service.
 */
private final synchronized void bindService(){
  if (serviceConnection == null) {
    serviceConnection=new ServiceConnection(){
      public void onServiceDisconnected(      ComponentName name){
      }
      public void onServiceConnected(      ComponentName name,      IBinder binder){
        service=IXmppTransportService.Stub.asInterface(binder);
      }
    }
;
  }
  authenticatorActivity.bindService(new Intent(IXmppTransportService.class.getName()),serviceConnection,Context.BIND_AUTO_CREATE);
}
 

Example 54

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

Source file: ServiceManager.java

  29 
vote

public void onServiceConnected(ComponentName className,IBinder service){
  resourceServiceBound=true;
  resourceMessenger=new Messenger(service);
  sendMessageToService(ResourceService.MSG_REGISTER_CLIENT);
  ListIterator<Message> iterator=messageQueue.listIterator();
  while (iterator.hasNext()) {
    sendMessageToService(iterator.next());
  }
  messageQueue.clear();
}
 

Example 55

From project BSPAN---Bluetooth-Sensor-Processing-for-Android, under directory /AndroidSpineServer/src/t2/spine/communication/android/.

Source file: AndroidMessageServer.java

  29 
vote

public void onServiceConnected(ComponentName className,IBinder service){
  mService=new Messenger(service);
  AndroidSpineServerMainActivity.getInstance().setmService(mService);
  Log.i(TAG,"Service Connected");
  try {
    Message msg=Message.obtain(null,MSG_REGISTER_CLIENT);
    msg.replyTo=mMessenger;
    mService.send(msg);
  }
 catch (  RemoteException e) {
    Log.e(TAG,"Remove exception " + e.toString());
  }
}
 

Example 56

From project btmidi, under directory /BluetoothMidiDemo/src/com/noisepages/nettoyeur/mididemo/.

Source file: PianoActivity.java

  29 
vote

@Override public void onServiceConnected(ComponentName name,IBinder service){
  midiService=((BluetoothMidiService.BluetoothMidiBinder)service).getService();
  try {
    midiService.init(observer,receiver);
  }
 catch (  IOException e) {
    toast("MIDI not available");
    finish();
  }
}
 

Example 57

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

Source file: Armser.java

  29 
vote

/** 
 * launch a activity via sent intent
 * @param className className of activity e.g."com.android.mms/.ui.ConversationList"
 * @param flags param for intent.setFlags()
 * @return whether the activity launched succeed
 */
public boolean launchActivity(String className,int flags){
  Intent intent=new Intent(Intent.ACTION_MAIN);
  intent.setComponent(ComponentName.unflattenFromString(className));
  intent.setFlags(flags);
  mContext.startActivity(intent);
  final String[] classShortName=className.split("\\.");
  return waitForActivity(classShortName[classShortName.length - 1],TIMEOUT_DEFAULT_VALUE);
}
 

Example 58

From project ChkBugReport, under directory /examples/testapp/src/com/sonymobile/chkbugreport/testapp/.

Source file: AIDLDeadlock.java

  29 
vote

/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  System.out.println(">>> onCreate");
  Intent service=new Intent(this,AIDLDeadlockService.class);
  ServiceConnection connection=new ServiceConnection(){
    @Override public void onServiceDisconnected(    ComponentName name){
    }
    @Override public void onServiceConnected(    ComponentName name,    IBinder service){
      mService=IDeadlock.Stub.asInterface(service);
      System.out.println(">>> onService Connected");
      try {
synchronized (LOCK1) {
          mService.setCallback(mCB);
          mService.doStep1();
        }
      }
 catch (      RemoteException e) {
        e.printStackTrace();
      }
    }
  }
;
  bindService(service,connection,BIND_AUTO_CREATE);
}
 

Example 59

From project cicada, under directory /cicada/src/org/cicadasong/cicada/.

Source file: Cicada.java

  29 
vote

/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  display=(SimulatedDisplayView)findViewById(R.id.display);
  serviceToggle=(ToggleButton)findViewById(R.id.service_toggle);
  serviceToggle.setOnCheckedChangeListener(new OnCheckedChangeListener(){
    @Override public void onCheckedChanged(    CompoundButton buttonView,    boolean isChecked){
      if (isChecked) {
        if (!checkSettingsAndStart()) {
          serviceToggle.setChecked(false);
        }
      }
 else {
        stopService(new Intent(getBaseContext(),CicadaService.class));
      }
    }
  }
);
  appSettingsButton=(Button)findViewById(R.id.active_app_settings);
  appSettingsButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      if (CicadaService.getActiveApp() != null && CicadaService.getActiveApp().settingsActivityClassName != null) {
        AppDescription app=CicadaService.getActiveApp();
        Intent intent=new Intent();
        intent.setComponent(new ComponentName(app.packageName,app.settingsActivityClassName));
        startActivity(intent);
      }
    }
  }
);
  updateServiceToggleState();
  if (!CicadaService.isRunning()) {
    checkSettingsAndStart();
  }
}
 

Example 60

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

Source file: CineShowTimeMovieFragment.java

  29 
vote

@Override public void onServiceConnected(ComponentName name,IBinder service){
  serviceMovie=IServiceMovie.Stub.asInterface(service);
  try {
    serviceMovie.registerCallback(m_callback);
  }
 catch (  RemoteException e) {
    e.printStackTrace();
  }
}
 

Example 61

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

Source file: ConsoleActivity.java

  29 
vote

public void onServiceConnected(ComponentName className,IBinder service){
  bound=((TerminalManager.TerminalBinder)service).getService();
  bound.disconnectHandler=disconnectHandler;
  Log.d(TAG,String.format("Connected to TerminalManager and found bridges.size=%d",bound.bridges.size()));
  bound.setResizeAllowed(true);
  bound.hardKeyboardHidden=(getResources().getConfiguration().hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES);
  if (bound.getFullScreen() == 0) {
    if (prefs.getBoolean(PreferenceConstants.FULLSCREEN,false))     setFullScreen(FULLSCREEN_ON);
 else     setFullScreen(FULLSCREEN_OFF);
  }
 else   if (fullScreen != bound.getFullScreen())   setFullScreen(bound.getFullScreen());
  flip.removeAllViews();
  final String requestedNickname=(requested != null) ? requested.getFragment() : null;
  int requestedIndex=-1;
  TerminalBridge requestedBridge=bound.getConnectedBridge(requestedNickname);
  if (requestedNickname != null && requestedBridge == null) {
    try {
      Log.d(TAG,String.format("We couldnt find an existing bridge with URI=%s (nickname=%s), so creating one now",requested.toString(),requestedNickname));
      requestedBridge=bound.openConnection(requested);
    }
 catch (    Exception e) {
      Log.e(TAG,"Problem while trying to create new requested bridge from URI",e);
    }
  }
  for (  TerminalBridge bridge : bound.bridges) {
    final int currentIndex=addNewTerminalView(bridge);
    if (bridge == requestedBridge) {
      requestedIndex=currentIndex;
      bound.defaultBridge=bridge;
    }
  }
  if (requestedIndex < 0) {
    requestedIndex=getFlipIndex(bound.defaultBridge);
    if (requestedIndex < 0)     requestedIndex=0;
  }
  setDisplayedTerminal(requestedIndex);
}