Java Code Examples for android.app.Activity

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 and-bible, under directory /AndBible/src/net/bible/android/control/search/.

Source file: SearchControl.java

  18 
vote

/** 
 * if current document is indexed then go to search else go to download index page
 * @return required Intent
 */
public Intent getSearchIntent(Book document){
  IndexStatus indexStatus=document.getIndexStatus();
  Log.d(TAG,"Index status:" + indexStatus);
  Activity currentActivity=CurrentActivityHolder.getInstance().getCurrentActivity();
  if (indexStatus.equals(IndexStatus.DONE)) {
    Log.d(TAG,"Index status is DONE");
    return new Intent(currentActivity,Search.class);
  }
 else {
    Log.d(TAG,"Index status is NOT DONE");
    return new Intent(currentActivity,SearchIndex.class);
  }
}
 

Example 2

From project Android, under directory /app/src/main/java/com/github/mobile/ui/gist/.

Source file: DeleteGistTask.java

  18 
vote

@Override protected void onSuccess(Gist gist) throws Exception {
  super.onSuccess(gist);
  Activity activity=(Activity)getContext();
  activity.setResult(RESULT_OK);
  activity.finish();
}
 

Example 3

From project android-marvin, under directory /marvin-it/src/test/android/de/akquinet/android/marvintest/.

Source file: ActivityControlTest.java

  18 
vote

public void testGetMostRecentlyStartedActivity(){
  final ActivityB startActivity=perform().startActivity(ActivityB.class);
  MatcherAssert.assertThat(startActivity,notNullValue());
  await().activity(ActivityB.class,10,TimeUnit.SECONDS);
  Activity recentlyStarted=getActivityMonitor().getMostRecentlyStartedActivity();
  MatcherAssert.assertThat(startActivity,sameInstance(recentlyStarted));
}
 

Example 4

From project Android-Simple-Social-Sharing, under directory /SimpleSocialSharingExample/src/com/nostra13/example/socialsharing/assist/.

Source file: FacebookEventObserver.java

  18 
vote

private void showToastOnUIThread(final int textRes){
  final Activity curActivity=context.get();
  if (curActivity != null) {
    curActivity.runOnUiThread(new Runnable(){
      @Override public void run(){
        Toast.makeText(curActivity,textRes,Toast.LENGTH_SHORT).show();
      }
    }
);
  }
}
 

Example 5

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

Source file: MusicUtils.java

  17 
vote

public static ServiceToken bindToService(final Activity context,final ServiceConnection callback){
  Activity realActivity=context.getParent();
  if (realActivity == null) {
    realActivity=context;
  }
  final ContextWrapper cw=new ContextWrapper(realActivity);
  cw.startService(new Intent(cw,PodcastPlaybackService.class));
  final ServiceBinder sb=new ServiceBinder(callback);
  if (cw.bindService((new Intent()).setClass(cw,PodcastPlaybackService.class),sb,0)) {
    sConnectionMap.put(cw,sb);
    return new ServiceToken(cw);
  }
  Log.e("Music","Failed to bind to service");
  return null;
}
 

Example 6

From project Android-automation, under directory /TmtsApp/src/com/taobao/tmts/framework/app/.

Source file: WebViewActivity.java

  17 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().requestFeature(Window.FEATURE_PROGRESS);
  this.requestWindowFeature(Window.FEATURE_NO_TITLE);
  Log.d("sysout","thread-->" + Thread.currentThread().getId());
  Log.d("sysout","activity-->" + Thread.currentThread().getName());
  setContentView(R.layout.webview_extend_layout);
  initWebView();
  final Activity activity=this;
  webview.setWebChromeClient(new WebChromeClient(){
    public void onProgressChanged(    WebView view,    int progress){
      activity.setProgress(progress * 1000);
    }
  }
);
  webview.setWebViewClient(new WebViewClient(){
    public void onReceivedError(    WebView view,    int errorCode,    String description,    String failingUrl){
      Toast.makeText(activity,"Oh no! " + description,Toast.LENGTH_LONG).show();
    }
    @Override public void onPageFinished(    WebView view,    String url){
      progressBar.setVisibility(View.GONE);
      button.setVisibility(View.VISIBLE);
    }
    @Override public boolean shouldOverrideUrlLoading(    WebView view,    String url){
      return super.shouldOverrideUrlLoading(view,url);
    }
  }
);
  webview.loadUrl(URL);
  webview.clearCache(true);
}
 

Example 7

From project Android-GifStitch, under directory /src/com/phunkosis/gifstitch/helpers/.

Source file: ImageLoader.java

  17 
vote

public void run(){
  try {
    while (true) {
      if (photosQueue.photosToLoad.size() == 0) synchronized (photosQueue.photosToLoad) {
        photosQueue.photosToLoad.wait();
      }
      if (photosQueue.photosToLoad.size() != 0) {
        PhotoToLoad photoToLoad;
synchronized (photosQueue.photosToLoad) {
          photoToLoad=photosQueue.photosToLoad.pop();
        }
        Bitmap bmp=getBitmap(photoToLoad.url,photoToLoad.width,photoToLoad.height,photoToLoad.useThumb);
        String tag=imageViews.get(photoToLoad.imageView);
        if (tag != null && tag.equals(photoToLoad.url)) {
          BitmapDisplayer bd=new BitmapDisplayer(bmp,photoToLoad.imageView);
          Activity a=(Activity)photoToLoad.imageView.getContext();
          a.runOnUiThread(bd);
        }
      }
      if (Thread.interrupted())       break;
    }
  }
 catch (  InterruptedException e) {
  }
}
 

Example 8

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

Source file: WindowListAdapter.java

  17 
vote

public View getView(int position,View convertView,ViewGroup parent){
  Activity act=(Activity)parent.getContext();
  View child=act.getLayoutInflater().inflate(R.layout.window_list_item,parent,false);
  View close=child.findViewById(R.id.window_list_close);
  TextView label=(TextView)child.findViewById(R.id.window_list_label);
  String defaultTitle=act.getString(R.string.window_title,position + 1);
  label.setText(getSessionTitle(position,defaultTitle));
  final SessionList sessions=mSessions;
  final int closePosition=position;
  close.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View v){
      TermSession session=sessions.remove(closePosition);
      if (session != null) {
        session.finish();
        notifyDataSetChanged();
      }
    }
  }
);
  return child;
}
 

Example 9

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/app/.

Source file: SherlockDialogFragment.java

  15 
vote

@Override public void onAttach(Activity activity){
  if (!(activity instanceof SherlockFragmentActivity)) {
    throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity.");
  }
  mActivity=(SherlockFragmentActivity)activity;
  super.onAttach(activity);
}
 

Example 10

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/app/.

Source file: SherlockDialogFragment.java

  15 
vote

@Override public void onAttach(Activity activity){
  if (!(activity instanceof SherlockFragmentActivity)) {
    throw new IllegalStateException(TAG + " must be attached to a SherlockFragmentActivity.");
  }
  mActivity=(SherlockFragmentActivity)activity;
  super.onAttach(activity);
}
 

Example 11

From project ActionBarCompat, under directory /ActionBarCompat/src/sk/m217/actionbarcompat/.

Source file: ActionBarCompatHoneycomb.java

  15 
vote

public static void setIcon(Activity activity,Drawable icon){
  View v=activity.findViewById(android.R.id.home);
  if (v != null && v instanceof ImageView) {
    ((ImageView)v).setImageDrawable(icon);
  }
}
 

Example 12

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

Source file: SherlockDialogFragment.java

  15 
vote

@Override public void onAttach(Activity activity){
  if (!(activity instanceof SherlockFragmentActivity)) {
    throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity.");
  }
  mActivity=(SherlockFragmentActivity)activity;
  super.onAttach(activity);
}
 

Example 13

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

Source file: CommitDetailsFragment.java

  15 
vote

@Override public void onAttach(Activity activity){
  super.onAttach(activity);
  if (activity instanceof CommitSelectedListener) {
    commitSelectedListener=(CommitSelectedListener)activity;
  }
}
 

Example 14

From project AirCastingAndroidClient, under directory /src/main/java/pl/llp/aircasting/activity/menu/.

Source file: MainMenu.java

  15 
vote

public boolean handleClick(Activity activity,MenuItem item){
switch (item.getItemId()) {
case R.id.aircasting:
    if (sessionManager.isSessionSaved()) {
      sessionManager.discardSession();
    }
  Intent intent=new Intent(context,SoundTraceActivity.class);
intent.putExtra("startingAircasting",true);
activity.startActivity(intent);
break;
case R.id.sessions:
activity.startActivity(new Intent(context,SessionsActivity.class));
break;
case R.id.settings:
activity.startActivity(new Intent(context,SettingsActivity.class));
break;
case R.id.about:
activity.startActivity(new Intent(context,AboutActivity.class));
break;
}
return true;
}
 

Example 15

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

Source file: AkRingtonePreference.java

  15 
vote

public AkRingtonePreference(Context context,AttributeSet attrs){
  super(context,attrs);
  Intent intent=((Activity)context).getIntent();
  mProviderId=intent.getLongExtra("providerId",-1);
  if (mProviderId < 0) {
    Log.e("Aksunai","RingtonePreference needs a provider id.");
  }
}
 

Example 16

From project AlarmApp-Android, under directory /src/org/alarmapp/util/.

Source file: ActivityUtil.java

  15 
vote

public static void displayToast(final Activity activity,final String text,final int duration){
  activity.runOnUiThread(new Runnable(){
    public void run(){
      Toast toast=Toast.makeText(activity,text,duration);
      toast.show();
    }
  }
);
}
 

Example 17

From project Alerte-voirie-android, under directory /src/com/fabernovel/alertevoirie/webservice/.

Source file: AVService.java

  15 
vote

public void toastServerError(){
  try {
    toastServerError(((Activity)context).getString(R.string.server_error));
  }
 catch (  Exception e) {
    Log.e(Constants.PROJECT_TAG,"Exception",e);
  }
}
 

Example 18

From project alljoyn_java, under directory /samples/android/chat/src/org/alljoyn/bus/sample/chat/.

Source file: DialogBuilder.java

  15 
vote

public Dialog createUseJoinDialog(final Activity activity,final ChatApplication application){
  Log.i(TAG,"createUseJoinDialog()");
  final Dialog dialog=new Dialog(activity);
  dialog.requestWindowFeature(dialog.getWindow().FEATURE_NO_TITLE);
  dialog.setContentView(R.layout.usejoindialog);
  ArrayAdapter<String> channelListAdapter=new ArrayAdapter<String>(activity,android.R.layout.test_list_item);
  final ListView channelList=(ListView)dialog.findViewById(R.id.useJoinChannelList);
  channelList.setAdapter(channelListAdapter);
  List<String> channels=application.getFoundChannels();
  for (  String channel : channels) {
    int lastDot=channel.lastIndexOf('.');
    if (lastDot < 0) {
      continue;
    }
    channelListAdapter.add(channel.substring(lastDot + 1));
  }
  channelListAdapter.notifyDataSetChanged();
  channelList.setOnItemClickListener(new ListView.OnItemClickListener(){
    public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      String name=channelList.getItemAtPosition(position).toString();
      application.useSetChannelName(name);
      application.useJoinChannel();
      activity.removeDialog(UseActivity.DIALOG_JOIN_ID);
    }
  }
);
  Button cancel=(Button)dialog.findViewById(R.id.useJoinCancel);
  cancel.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View view){
      activity.removeDialog(UseActivity.DIALOG_JOIN_ID);
    }
  }
);
  return dialog;
}
 

Example 19

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

Source file: SherlockDialogFragment.java

  15 
vote

@Override public void onAttach(Activity activity){
  if (!(activity instanceof SherlockFragmentActivity)) {
    throw new IllegalStateException(TAG + " must be attached to a SherlockFragmentActivity.");
  }
  mActivity=(SherlockFragmentActivity)activity;
  super.onAttach(activity);
}
 

Example 20

From project AmDroid, under directory /AmDroid/src/main/java/com/jaeckel/amenoid/cwac/thumbnail/.

Source file: ThumbnailAdapter.java

  15 
vote

/** 
 * Constructor wrapping a supplied ListAdapter
 */
public ThumbnailAdapter(Activity host,ListAdapter wrapped,SimpleWebImageCache<ThumbnailBus,ThumbnailMessage> cache,int[] imageIds){
  super(wrapped);
  this.host=host;
  this.imageIds=imageIds;
  this.cache=cache;
  cache.getBus().register(getBusKey(),onCache);
}
 

Example 21

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

Source file: SherlockDialogFragment.java

  15 
vote

@Override public void onAttach(Activity activity){
  if (!(activity instanceof SherlockFragmentActivity)) {
    throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity.");
  }
  mActivity=(SherlockFragmentActivity)activity;
  super.onAttach(activity);
}
 

Example 22

From project android-api-demos, under directory /src/com/mobeelizer/demos/activities/.

Source file: ConflictsDetailsActivity.java

  15 
vote

/** 
 * {@inheritDoc} <br/><br/> When the user clicks the desired rating  {@link ConflictsDetailsActivity} is finishes and the rating is returned as aresult.
 */
public void onClick(final View v){
  int newRating=-1;
switch (v.getId()) {
case R.id.detailsStar1:
    mRadioGroup.check(R.id.detailsRStar1);
  newRating=1;
break;
case R.id.detailsStar2:
mRadioGroup.check(R.id.detailsRStar2);
newRating=2;
break;
case R.id.detailsStar3:
mRadioGroup.check(R.id.detailsRStar3);
newRating=3;
break;
case R.id.detailsStar4:
mRadioGroup.check(R.id.detailsRStar4);
newRating=4;
break;
case R.id.detailsStar5:
mRadioGroup.check(R.id.detailsRStar5);
newRating=5;
break;
}
if (newRating != -1) {
Intent i=getIntent();
i.putExtra(RATING,newRating);
setResult(Activity.RESULT_OK,i);
}
 else {
setResult(Activity.RESULT_CANCELED);
}
finish();
}
 

Example 23

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

Source file: Helpers.java

  15 
vote

static public void setActivityAnimation(Activity activity,int in,int out){
  try {
    Method method=Activity.class.getMethod("overridePendingTransition",new Class[]{int.class,int.class});
    method.invoke(activity,in,out);
  }
 catch (  Exception e) {
  }
}
 

Example 24

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

Source file: XwikiNavigator.java

  15 
vote

protected void onActivityResult(int requestCode,int resultCode,Intent data){
  if (requestCode == REQUEST_CODE_XWIKI_NAVIGATOR) {
    if (resultCode == Activity.RESULT_OK) {
      String wikiName=data.getExtras().getString(XWikiListNavigatorActivity.INTENT_EXTRA_GET_WIKI_NAME);
      String spaceName=data.getExtras().getString(XWikiListNavigatorActivity.INTENT_EXTRA_GET_SPACE_NAME);
      String pageName=data.getExtras().getString(XWikiListNavigatorActivity.INTENT_EXTRA_GET_PAGE_NAME);
      Intent intent=new Intent(this,PageViewActivity.class);
      intent.putExtra(PageViewActivity.INTENT_EXTRA_PUT_USERNAME,username);
      intent.putExtra(PageViewActivity.INTENT_EXTRA_PUT_PASSWORD,password);
      intent.putExtra(PageViewActivity.INTENT_EXTRA_PUT_URL,url);
      intent.putExtra(PageViewActivity.INTENT_EXTRA_PUT_WIKI_NAME,wikiName);
      intent.putExtra(PageViewActivity.INTENT_EXTRA_PUT_SPACE_NAME,spaceName);
      intent.putExtra(PageViewActivity.INTENT_EXTRA_PUT_PAGE_NAME,pageName);
      startActivityForResult(intent,REQUEST_CODE_XWIKI_PAGEVIEWER);
    }
  }
 else   if (requestCode == REQUEST_CODE_XWIKI_PAGEVIEWER) {
    startXWikiNavigator();
  }
}
 

Example 25

From project android-client_2, under directory /src/org/mifos/androidclient/main/.

Source file: AccountDetailsActivity.java

  15 
vote

@Override protected void onActivityResult(int requestCode,int resultCode,Intent data){
  super.onActivityResult(requestCode,resultCode,data);
switch (resultCode) {
case Activity.RESULT_OK:
    runAccountDetailsTask();
  break;
case Activity.RESULT_CANCELED:
break;
default :
break;
}
}
 

Example 26

From project Android-FFXIEQ, under directory /ffxieq/src/com/github/kanata3249/ffxieq/android/.

Source file: AtmaSelector.java

  15 
vote

static public boolean startActivity(Activity from,int request,FFXICharacter charInfo,int index,long current){
  Intent intent=new Intent(from,AtmaSelector.class);
  intent.putExtra("Current",current);
  intent.putExtra("Index",index);
  intent.putExtra("Filter",(long)-1);
  from.startActivityForResult(intent,request);
  return true;
}
 

Example 27

From project Android-File-Manager, under directory /src/com/nexes/manager/.

Source file: EventHandler.java

  15 
vote

/** 
 * This will turn off multi-select and hide the multi-select buttons at the bottom of the view. 
 * @param clearData if this is true any files/folders the user selected for multi-selectwill be cleared. If false, the data will be kept for later use. Note: multi-select copy and move will usually be the only one to pass false,  so we can later paste it to another folder.
 */
public void killMultiSelect(boolean clearData){
  hidden_layout=(LinearLayout)((Activity)mContext).findViewById(R.id.hidden_buttons);
  hidden_layout.setVisibility(LinearLayout.GONE);
  multi_select_flag=false;
  if (positions != null && !positions.isEmpty())   positions.clear();
  if (clearData)   if (mMultiSelectData != null && !mMultiSelectData.isEmpty())   mMultiSelectData.clear();
  notifyDataSetChanged();
}
 

Example 28

From project Android-File-Manager-Tablet, under directory /src/com/nexes/manager/tablet/.

Source file: BluetoothActivity.java

  15 
vote

@Override protected void onActivityResult(int requestCode,int resultCode,Intent data){
  if (requestCode == REQUEST_ENABLE && resultCode == Activity.RESULT_OK) {
    mMessageView.setText("Bluetooth is turned on.");
    mButton.setText("Scan for Devices");
    mButton.setId(BUTTON_FIND);
    findPairedDevices();
  }
 else   if (requestCode == REQUEST_ENABLE && resultCode == Activity.RESULT_CANCELED) {
    Toast.makeText(this,"Bluetooth was not be turned on.",Toast.LENGTH_LONG).show();
    finish();
  }
}
 

Example 29

From project android-flash-cards, under directory /src/org/thomasamsler/android/flashcards/conversion/.

Source file: FileToDbConversion.java

  15 
vote

@Override protected void onPostExecute(List<CardSet> cardSets){
  MainApplication mainApplication=(MainApplication)((Activity)mContext).getApplication();
  for (  CardSet cardSet : cardSets) {
    mainApplication.doAction(ACTION_ADD_CARD_SET,cardSet);
  }
  mDialog.cancel();
}
 

Example 30

From project android-flip, under directory /FlipView/Demo/src/com/aphidmobile/flip/demo/.

Source file: MainActivity.java

  15 
vote

private void addItem(List<Map<String,Object>> data,String title,Class<? extends Activity> activityClass){
  Map<String,Object> map=new HashMap<String,Object>();
  map.put("title",title);
  map.put("activity",activityClass);
  data.add(map);
}
 

Example 31

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

Source file: Facebook.java

  15 
vote

/** 
 * Full authorize method. Starts either an Activity or a dialog which prompts the user to log in to Facebook and grant the requested permissions to the given application. This method will, when possible, use Facebook's single sign-on for Android to obtain an access token. This involves proxying a call through the Facebook for Android stand-alone application, which will handle the authentication flow, and return an OAuth access token for making API calls. Because this process will not be available for all users, if single sign-on is not possible, this method will automatically fall back to the OAuth 2.0 User-Agent flow. In this flow, the user credentials are handled by Facebook in an embedded WebView, not by the client application. As such, the dialog makes a network request and renders HTML content rather than a native UI. The access token is retrieved from a redirect to a special URL that the WebView handles. Note that User credentials could be handled natively using the OAuth 2.0 Username and Password Flow, but this is not supported by this SDK. See http://developers.facebook.com/docs/authentication/ and http://wiki.oauth.net/OAuth-2 for more details. Note that this method is asynchronous and the callback will be invoked in the original calling thread (not in a background thread). Also note that requests may be made to the API without calling authorize first, in which case only public information is returned. IMPORTANT: Note that single sign-on authentication will not function correctly if you do not include a call to the authorizeCallback() method in your onActivityResult() function! Please see below for more information. single sign-on may be disabled by passing FORCE_DIALOG_AUTH as the activityCode parameter in your call to authorize().
 * @param activity The Android activity in which we want to display the authorization dialog.
 * @param applicationId The Facebook application identifier e.g. "350685531728"
 * @param permissions A list of permissions required for this application: e.g. "read_stream", "publish_stream", "offline_access", etc. see http://developers.facebook.com/docs/authentication/permissions This parameter should not be null -- if you do not require any permissions, then pass in an empty String array.
 * @param activityCode Single sign-on requires an activity result to be called back to the client application -- if you are waiting on other activities to return data, pass a custom activity code here to avoid collisions. If you would like to force the use of legacy dialog-based authorization, pass FORCE_DIALOG_AUTH for this parameter. Otherwise just omit this parameter and Facebook will use a suitable default. See http://developer.android.com/reference/android/ app/Activity.html for more information.
 * @param listener Callback interface for notifying the calling application when the authentication dialog has completed, failed, or been canceled.
 */
public void authorize(Activity activity,String[] permissions,int activityCode,final DialogListener listener){
  boolean singleSignOnStarted=false;
  mAuthDialogListener=listener;
  autoPublishAsync(activity.getApplicationContext());
  if (activityCode >= 0) {
    singleSignOnStarted=startSingleSignOn(activity,mAppId,permissions,activityCode);
  }
  if (!singleSignOnStarted) {
    startDialogAuth(activity,permissions);
  }
}
 

Example 32

From project Android-MapForgeFragment, under directory /library-common/src/com/jakewharton/android/mapsforge_fragment/.

Source file: MapView.java

  15 
vote

MultiTouchHandler(Activity activity,MapView mapView){
  super(activity,mapView);
  this.mapView=mapView;
  this.activePointerId=INVALID_POINTER_ID;
  this.scaleGestureDetector=new ScaleGestureDetector(activity,new ScaleListener(mapView));
}
 

Example 33

From project android-ocr, under directory /android/src/edu/sfsu/cs/orange/ocr/language/.

Source file: Translator.java

  15 
vote

static String translate(Activity activity,String sourceLanguageCode,String targetLanguageCode,String sourceText){
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(activity);
  String api=prefs.getString(PreferencesActivity.KEY_TRANSLATOR,CaptureActivity.DEFAULT_TRANSLATOR);
  if (api.equals(PreferencesActivity.TRANSLATOR_BING)) {
    sourceLanguageCode=TranslatorBing.toLanguage(LanguageCodeHelper.getTranslationLanguageName(activity.getBaseContext(),sourceLanguageCode));
    return TranslatorBing.translate(sourceLanguageCode,targetLanguageCode,sourceText);
  }
 else   if (api.equals(PreferencesActivity.TRANSLATOR_GOOGLE)) {
    sourceLanguageCode=TranslatorGoogle.toLanguage(LanguageCodeHelper.getTranslationLanguageName(activity.getBaseContext(),sourceLanguageCode));
    return TranslatorGoogle.translate(sourceLanguageCode,targetLanguageCode,sourceText);
  }
  return BAD_TRANSLATION_MSG;
}
 

Example 34

From project android-rackspacecloud, under directory /src/com/rackspacecloud/android/.

Source file: AccessControlActivity.java

  15 
vote

@Override protected void onPostExecute(HttpBundle bundle){
  HttpResponse response=bundle.getResponse();
  if (response != null) {
    int statusCode=response.getStatusLine().getStatusCode();
    if (statusCode == 202 || statusCode == 200) {
      setResult(Activity.RESULT_OK);
      loadNetworkItems();
    }
 else {
      CloudServersException cse=parseCloudServersException(response);
      if ("".equals(cse.getMessage())) {
        showError("There was a problem deleting your rule.",bundle);
      }
 else {
        showError("There was a problem deleting your rule: " + cse.getMessage(),bundle);
      }
    }
  }
 else   if (exception != null) {
    showError("There was a problem deleting your rule: " + exception.getMessage(),bundle);
  }
}
 

Example 35

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

Source file: BootstrapActivity.java

  15 
vote

@Override protected void onCreate(Bundle icicle){
  super.onCreate(icicle);
  Class<? extends Activity> activityClass=null;
  boolean firstTime=Preferences.isFirstTime(this);
  if (firstTime) {
    Log.i(cTag,"First time using Shuffle. Show intro screen");
    activityClass=WelcomeActivity.class;
  }
 else {
    activityClass=TopLevelActivity.class;
  }
  startService(new Intent(this,SynchronizationService.class));
  startActivity(new Intent(this,activityClass));
  finish();
}
 

Example 36

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

Source file: Facebook.java

  15 
vote

/** 
 * Full authorize method. Starts either an Activity or a dialog which prompts the user to log in to Facebook and grant the requested permissions to the given application. This method will, when possible, use Facebook's single sign-on for Android to obtain an access token. This involves proxying a call through the Facebook for Android stand-alone application, which will handle the authentication flow, and return an OAuth access token for making API calls. Because this process will not be available for all users, if single sign-on is not possible, this method will automatically fall back to the OAuth 2.0 User-Agent flow. In this flow, the user credentials are handled by Facebook in an embedded WebView, not by the client application. As such, the dialog makes a network request and renders HTML content rather than a native UI. The access token is retrieved from a redirect to a special URL that the WebView handles. Note that User credentials could be handled natively using the OAuth 2.0 Username and Password Flow, but this is not supported by this SDK. See http://developers.facebook.com/docs/authentication/ and http://wiki.oauth.net/OAuth-2 for more details. Note that this method is asynchronous and the callback will be invoked in the original calling thread (not in a background thread). Also note that requests may be made to the API without calling authorize first, in which case only public information is returned. IMPORTANT: Note that single sign-on authentication will not function correctly if you do not include a call to the authorizeCallback() method in your onActivityResult() function! Please see below for more information. single sign-on may be disabled by passing FORCE_DIALOG_AUTH as the activityCode parameter in your call to authorize().
 * @param activity The Android activity in which we want to display the authorization dialog.
 * @param applicationId The Facebook application identifier e.g. "350685531728"
 * @param permissions A list of permissions required for this application: e.g. "read_stream", "publish_stream", "offline_access", etc. see http://developers.facebook.com/docs/authentication/permissions This parameter should not be null -- if you do not require any permissions, then pass in an empty String array.
 * @param activityCode Single sign-on requires an activity result to be called back to the client application -- if you are waiting on other activities to return data, pass a custom activity code here to avoid collisions. If you would like to force the use of legacy dialog-based authorization, pass FORCE_DIALOG_AUTH for this parameter. Otherwise just omit this parameter and Facebook will use a suitable default. See http://developer.android.com/reference/android/ app/Activity.html for more information.
 * @param listener Callback interface for notifying the calling application when the authentication dialog has completed, failed, or been canceled.
 */
public void authorize(Activity activity,String[] permissions,int activityCode,final DialogListener listener){
  boolean singleSignOnStarted=false;
  mAuthDialogListener=listener;
  if (activityCode >= 0) {
    singleSignOnStarted=startSingleSignOn(activity,mAppId,permissions,activityCode);
  }
  if (!singleSignOnStarted) {
    startDialogAuth(activity,permissions);
  }
}
 

Example 37

From project android-thaiime, under directory /latinime/src/com/sugree/inputmethod/latin/.

Source file: Settings.java

  15 
vote

public Activity getActivityInternal(){
  Object thisObject=(Object)this;
  if (thisObject instanceof Activity) {
    return (Activity)thisObject;
  }
 else   if (thisObject instanceof Fragment) {
    return ((Fragment)thisObject).getActivity();
  }
 else {
    return null;
  }
}
 

Example 38

From project android-xbmcremote, under directory /src/org/xbmc/android/remote/presentation/activity/.

Source file: ConfigurationManager.java

  15 
vote

private ConfigurationManager(Activity activity){
  mActivity=activity;
  final SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(mActivity);
  prefs.registerOnSharedPreferenceChangeListener(this);
  mKeyguardState=Integer.parseInt(prefs.getString(PREF_KEYGUARD_DISABLED,KEYGUARD_STATUS_ENABLED));
}