Example usage for android.app AlertDialog setMessage

List of usage examples for android.app AlertDialog setMessage

Introduction

In this page you can find the example usage for android.app AlertDialog setMessage.

Prototype

public void setMessage(CharSequence message) 

Source Link

Usage

From source file:net.homelinux.penecoptero.android.citybikes.donation.app.MainActivity.java

private void fillData(boolean all) {
    if (mNDBAdapter != null && mNDBAdapter.isConfigured()) {
        Bundle data = new Bundle();
        if (!all) {
            GeoPoint center = locator.getCurrentGeoPoint();

            if (center == null) {

                //Do something..
                int nid = settings.getInt("network_id", -1);
                //Log.i("CityBikes","Current network is id: "+Integer.toString(nid));
                if (nid != -1) {
                    try {
                        mNDBAdapter.load();
                        JSONObject network = mNDBAdapter.getNetworks(nid);
                        //Log.i("CityBikes",network.toString());
                        double lat = Integer.parseInt(network.getString("lat")) / 1E6;
                        double lng = Integer.parseInt(network.getString("lng")) / 1E6;
                        Location fallback = new Location("fallback");
                        fallback.setLatitude(lat);
                        fallback.setLongitude(lng);
                        locator.setFallbackLocation(fallback);
                        locator.unlockCenter();
                        center = locator.getCurrentGeoPoint();
                    } catch (Exception e) {
                        //Log.i("CityBikes","We re fucked, that network aint existin");
                        e.printStackTrace();
                    }//from  w w  w.j av a  2s  . com
                } else {
                    //Log.i("CityBikes","We re fucked, why re we here?");
                }
            }
            data.putInt(StationsDBAdapter.CENTER_LAT_KEY, center.getLatitudeE6());
            data.putInt(StationsDBAdapter.CENTER_LNG_KEY, center.getLongitudeE6());
            data.putInt(StationsDBAdapter.RADIUS_KEY, hOverlay.getRadius());
        }

        progressDialog = new ProgressDialog(this);
        progressDialog.setTitle("");
        progressDialog.setMessage(getString(R.string.loading));
        progressDialog.show();
        try {
            mDbHelper.sync(all, data);
        } catch (Exception e) {
            ////Log.i("openBicing", "Error Updating?");
            e.printStackTrace();
            progressDialog.dismiss();
        }
        ;
    } else {
        //Log.i("CityBikes","First time!!! :D");
        try {
            mNDBAdapter.update();
            AlertDialog alertDialog = new AlertDialog.Builder(this).create();
            alertDialog.setIcon(android.R.drawable.ic_dialog_map);
            alertDialog.setTitle(R.string.bike_network_alert_title);
            alertDialog.setMessage(getString(R.string.bike_network_alert_text));
            alertDialog.setButton(getString(R.string.automatic), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub

                }

            });
            alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.automatic),
                    new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                            showAutoNetworkDialog(0);

                        }

                    });
            alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.manual),
                    new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            showBikeNetworks();
                        }

                    });
            alertDialog.show();
        } catch (Exception e) {
            e.printStackTrace();
            Toast toast = Toast.makeText(getApplicationContext(), getString(R.string.network_error),
                    Toast.LENGTH_LONG);
            toast.show();
        }
    }
}

From source file:fm.smart.r1.activity.ItemActivity.java

public void addToList(final String item_id) {
    final ProgressDialog myOtherProgressDialog = new ProgressDialog(this);
    myOtherProgressDialog.setTitle("Please Wait ...");
    myOtherProgressDialog.setMessage("Adding item to study list ...");
    myOtherProgressDialog.setIndeterminate(true);
    myOtherProgressDialog.setCancelable(true);

    final Thread add = new Thread() {
        public void run() {
            ItemActivity.add_item_result = addItemToList(Main.default_study_list_id, item_id,
                    ItemActivity.this);

            myOtherProgressDialog.dismiss();
            ItemActivity.this.runOnUiThread(new Thread() {
                public void run() {
                    final AlertDialog dialog = new AlertDialog.Builder(ItemActivity.this).create();
                    dialog.setTitle(ItemActivity.add_item_result.getTitle());
                    dialog.setMessage(ItemActivity.add_item_result.getMessage());
                    ItemActivity.add_item_result = null;
                    dialog.setButton("OK", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                        }/*w w  w  .  j a v  a  2 s  .  c  om*/
                    });

                    dialog.show();
                }
            });

        }
    };
    myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            add.interrupt();
        }
    });
    OnCancelListener ocl = new OnCancelListener() {
        public void onCancel(DialogInterface arg0) {
            add.interrupt();
        }
    };
    myOtherProgressDialog.setOnCancelListener(ocl);
    closeMenu();
    myOtherProgressDialog.show();
    add.start();
}

From source file:net.homelinux.penecoptero.android.citybikes.app.MainActivity.java

private void fillData(boolean all) {
    if (mNDBAdapter != null && mNDBAdapter.isConfigured()) {
        Bundle data = new Bundle();
        if (!all) {
            GeoPoint center = locator.getCurrentGeoPoint();

            if (center == null) {

                //Do something..
                int nid = settings.getInt("network_id", -1);
                //Log.i("CityBikes","Current network is id: "+Integer.toString(nid));
                if (nid != -1) {
                    try {
                        mNDBAdapter.load();
                        JSONObject network = mNDBAdapter.getNetworks(nid);
                        //Log.i("CityBikes",network.toString());
                        double lat = Integer.parseInt(network.getString("lat")) / 1E6;
                        double lng = Integer.parseInt(network.getString("lng")) / 1E6;
                        Location fallback = new Location("fallback");
                        fallback.setLatitude(lat);
                        fallback.setLongitude(lng);
                        locator.setFallbackLocation(fallback);
                        locator.unlockCenter();
                        center = locator.getCurrentGeoPoint();
                    } catch (Exception e) {
                        //Log.i("CityBikes","We re fucked, that network aint existin");
                        e.printStackTrace();
                    }/* w  w w  .  java2s . c o  m*/
                } else {
                    //Log.i("CityBikes","We re fucked, why re we here?");
                }
            }
            data.putInt(StationsDBAdapter.CENTER_LAT_KEY, center.getLatitudeE6());
            data.putInt(StationsDBAdapter.CENTER_LNG_KEY, center.getLongitudeE6());
            data.putInt(StationsDBAdapter.RADIUS_KEY, hOverlay.getRadius());
        }

        progressDialog = new ProgressDialog(this);
        progressDialog.setTitle("");
        progressDialog.setMessage(getString(R.string.loading));
        progressDialog.show();
        try {
            mDbHelper.sync(all, data);
        } catch (Exception e) {
            ////Log.i("openBicing", "Error Updating?");
            e.printStackTrace();
            progressDialog.dismiss();
        }
        ;
    } else {
        //Log.i("CityBikes","First time!!! :D");
        try {
            mNDBAdapter.update();
            AlertDialog alertDialog = new AlertDialog.Builder(this).create();
            alertDialog.setIcon(android.R.drawable.ic_dialog_map);
            alertDialog.setTitle(R.string.bike_network_alert_title);
            alertDialog.setMessage(getString(R.string.bike_network_alert_text));
            alertDialog.setButton(getString(R.string.automatic), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub

                }

            });
            alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.automatic),
                    new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                            showAutoNetworkDialog(0);

                        }

                    });
            alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.manual),
                    new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            showBikeNetworks();
                        }

                    });
            alertDialog.show();
        } catch (Exception e) {
            e.printStackTrace();
            Toast toast = Toast.makeText(getApplicationContext(), getString(R.string.network_error),
                    Toast.LENGTH_LONG);
            toast.show();
        }
    }
    infoLayer.update();
}

From source file:bikebadger.RideFragment.java

public void onInit(int initStatus) {
    // assert  (false);
    //check for successful instantiation
    if (initStatus == TextToSpeech.SUCCESS) {
        //if(RideManager.mTTS.isLanguageAvailable(Locale.US)==TextToSpeech.LANG_AVAILABLE)
        //  RideManager.mTTS.setLanguage(Locale.US);
    } else if (initStatus == TextToSpeech.ERROR) {
        Toast.makeText(mRideManager.mAppContext, "Sorry! Text To Speech failed...", Toast.LENGTH_LONG).show();
        AlertDialog ad = new AlertDialog.Builder(getActivity()).create();
        ad.setCancelable(false);//from www  .ja va2s .  c om
        ad.setTitle("Text To Speech Engine Not Found");
        ad.setMessage(
                "There was a problem finding the Text To Speech Engine. Make sure it's install properly under Language and Input Settings.");
        ad.setButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        ad.show();
    }
}

From source file:se.lu.nateko.edca.BackboneSvc.java

/**
  * Method that displays an alert dialog to the user showing the string argument as the message text.
  * @param message Message to display in the alert dialog.
  * @param target The activity to display the AlertDialog in, pass null to default to the "active" Activity.
  *//*from  www .  j  a  v  a  2  s . c o  m*/
public void showAlertDialog(String message, Activity target) {
    Log.d(TAG, "showAlertDialog(String) called.");
    final String msg = message;
    final Activity tg = target;
    /*
      * By sending the code in "action" to the runOnUiThread() method from a separate thread,
      * its code will be placed in the UI Thread Message queue and thus happen after other
      * queued messages (such as displaying the layout).
      */
    new Thread(new Runnable() {
        public void run() {
            Runnable action = new Runnable() {
                public void run() {
                    /* The following is put on the Message queue. */
                    AlertDialog alertDialog = new AlertDialog.Builder((tg == null) ? getActiveActivity() : tg)
                            .create();
                    alertDialog.setMessage(msg);

                    /* Add a button to the dialog and set its text and button listener. */
                    alertDialog.setButton(
                            alertDialog.getContext().getString(R.string.service_alert_buttontext_ok),
                            new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                }
                            });
                    alertDialog.show(); // Display the dialog to the user.
                }
            };
            ((tg == null) ? getActiveActivity() : tg).runOnUiThread(action);
        }
    }).start();

}

From source file:fm.smart.r1.ItemActivity.java

public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    // this should be called once image has been chosen by user
    // using requestCode to pass item id - haven't worked out any other way
    // to do it//from w w w .j  a  v  a2 s . c om
    // if (requestCode == SELECT_IMAGE)
    if (resultCode == Activity.RESULT_OK) {
        // TODO check if user is logged in
        if (LoginActivity.isNotLoggedIn(this)) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setClassName(this, LoginActivity.class.getName());
            intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
            // avoid navigation back to this?
            LoginActivity.return_to = ItemActivity.class.getName();
            LoginActivity.params = new HashMap<String, String>();
            LoginActivity.params.put("item_id", (String) item.getId());
            startActivity(intent);
            // TODO in this case forcing the user to rechoose the image
            // seems a little
            // rude - should probably auto-submit here ...
        } else {
            // Bundle extras = data.getExtras();
            // String sentence_id = (String) extras.get("sentence_id");
            final ProgressDialog myOtherProgressDialog = new ProgressDialog(this);
            myOtherProgressDialog.setTitle("Please Wait ...");
            myOtherProgressDialog.setMessage("Uploading image ...");
            myOtherProgressDialog.setIndeterminate(true);
            myOtherProgressDialog.setCancelable(true);

            final Thread add_image = new Thread() {
                public void run() {
                    // TODO needs to check for interruptibility

                    String sentence_id = Integer.toString(requestCode);
                    Uri selectedImage = data.getData();
                    // Bitmap bitmap = Media.getBitmap(getContentResolver(),
                    // selectedImage);
                    // ByteArrayOutputStream bytes = new
                    // ByteArrayOutputStream();
                    // bitmap.compress(Bitmap.CompressFormat.JPEG, 40,
                    // bytes);
                    // ByteArrayInputStream fileInputStream = new
                    // ByteArrayInputStream(
                    // bytes.toByteArray());

                    // TODO Might have to save to file system first to get
                    // this
                    // to work,
                    // argh!
                    // could think of it as saving to cache ...

                    // add image to sentence
                    FileInputStream is = null;
                    FileOutputStream os = null;
                    File file = null;
                    ContentResolver resolver = getContentResolver();
                    try {
                        Bitmap bitmap = Media.getBitmap(getContentResolver(), selectedImage);
                        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
                        bitmap.compress(Bitmap.CompressFormat.JPEG, 40, bytes);
                        // ByteArrayInputStream bais = new
                        // ByteArrayInputStream(bytes.toByteArray());

                        // FileDescriptor fd =
                        // resolver.openFileDescriptor(selectedImage,
                        // "r").getFileDescriptor();
                        // is = new FileInputStream(fd);

                        String filename = "test.jpg";
                        File dir = ItemActivity.this.getDir("images", MODE_WORLD_READABLE);
                        file = new File(dir, filename);
                        os = new FileOutputStream(file);

                        // while (bais.available() > 0) {
                        // / os.write(bais.read());
                        // }
                        os.write(bytes.toByteArray());

                        os.close();

                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } finally {
                        if (os != null) {
                            try {
                                os.close();
                            } catch (IOException e) {
                            }
                        }
                        if (is != null) {
                            try {
                                is.close();
                            } catch (IOException e) {
                            }
                        }
                    }

                    // File file = new
                    // File(Uri.decode(selectedImage.toString()));

                    // ensure item is in users default list

                    ItemActivity.add_item_result = new AddItemResult(Main.lookup.addItemToGoal(Main.transport,
                            Main.default_study_goal_id, item.getId(), null));

                    Result result = ItemActivity.add_item_result;

                    if (ItemActivity.add_item_result.success()
                            || ItemActivity.add_item_result.alreadyInList()) {

                        // ensure sentence is in users default goal

                        ItemActivity.add_sentence_goal_result = new AddSentenceResult(
                                Main.lookup.addSentenceToGoal(Main.transport, Main.default_study_goal_id,
                                        item.getId(), sentence_id, null));

                        result = ItemActivity.add_sentence_goal_result;
                        if (ItemActivity.add_sentence_goal_result.success()) {

                            String media_entity = "http://test.com/test.jpg";
                            String author = "tansaku";
                            String author_url = "http://smart.fm/users/tansaku";
                            Log.d("DEBUG-IMAGE-URI", selectedImage.toString());
                            ItemActivity.add_image_result = addImage(file, media_entity, author, author_url,
                                    "1", sentence_id, (String) item.getId(), Main.default_study_goal_id);
                            result = ItemActivity.add_image_result;
                        }
                    }
                    final Result display = result;
                    myOtherProgressDialog.dismiss();
                    ItemActivity.this.runOnUiThread(new Thread() {
                        public void run() {
                            final AlertDialog dialog = new AlertDialog.Builder(ItemActivity.this).create();
                            dialog.setTitle(display.getTitle());
                            dialog.setMessage(display.getMessage());
                            dialog.setButton("OK", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    if (ItemActivity.add_image_result != null
                                            && ItemActivity.add_image_result.success()) {
                                        ItemListActivity.loadItem(ItemActivity.this, item.getId().toString());
                                    }
                                }
                            });

                            dialog.show();
                        }
                    });

                }

            };

            myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    add_image.interrupt();
                }
            });
            OnCancelListener ocl = new OnCancelListener() {
                public void onCancel(DialogInterface arg0) {
                    add_image.interrupt();
                }
            };
            myOtherProgressDialog.setOnCancelListener(ocl);
            closeMenu();
            myOtherProgressDialog.show();
            add_image.start();

        }
    }
}

From source file:hr.foicore.varazdinlandmarksdemo.POIMapActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    int id = item.getItemId();
    if (id == R.id.action_view_as_grid) {
        Intent i = new Intent(POIMapActivity.this, POIGridActivity.class);

        i.putExtra("playOn", mActionPlay);

        i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        // finish();
        overridePendingTransition(0, 0);

        startActivityForResult(i, 1);/*www  .  j  a va  2  s .c  o  m*/
        overridePendingTransition(0, 0);

    } else if (id == R.id.action_directions) {

        if (mActionDirections == 1) { // cancel directions action
            item.setIcon(R.drawable.ic_action_directions);
            mActionDirections = 0;
            tvMapDirectionsInfo.setVisibility(View.INVISIBLE);
            if (mRoute != null) {
                mRoute.remove();
            }
        } else if (mActionDirections == 0) { // set directions action on

            item.setIcon(R.drawable.ic_action_directions_pressed);
            mActionDirections = 1;

            gmm.handleMapWarningMessages(POIMapActivity.this, tvMapMessage);
            if (gmm.myLocationEnabled && gmm.internetEnabled) {
                Toast.makeText(POIMapActivity.this,
                        POIMapActivity.this.getResources().getString(R.string.tap_route_destination),
                        Toast.LENGTH_SHORT).show();

            } else {
                tvMapMessage.setBackgroundColor(
                        POIMapActivity.this.getResources().getColor(R.color.red_transparent));

                item.setIcon(R.drawable.ic_action_directions);
                mActionDirections = 0;
                tvMapDirectionsInfo.setVisibility(View.INVISIBLE);

            }
        } else { // mActionDirections == 3
            item.setIcon(R.drawable.ic_action_directions);
            mActionDirections = 0;
            tvMapDirectionsInfo.setVisibility(View.INVISIBLE);
            if (mRoute != null) {
                mRoute.remove();
            }
        }

    } else if (id == R.id.action_play) {

        if (mActionPlay) { // cancel play mode
            gmm.addAllMarkers(POIMapActivity.this);
            item.setIcon(R.drawable.ic_action_play);
            mActionPlay = false;

            miDirections.setIcon(R.drawable.ic_action_directions);
            mActionDirections = 0;
            tvMapDirectionsInfo.setVisibility(View.INVISIBLE);
            if (mRoute != null) {
                mRoute.remove();
            }
        } else {
            gmm.addPlayMarkers(POIMapActivity.this);
            item.setIcon(R.drawable.ic_action_pause_red);
            if (gmm.activePOIMarker != null) {
                drawUserDestRoute(gmm.activePOIMarker.getPosition());
            }
            mActionPlay = true;

        }

    } else if (id == R.id.action_google_map_type) {
        // get google map type names
        String[] googleMapTypeNames = getResources().getStringArray(R.array.google_map_type_names);

        // creating and Building the Dialog
        AlertDialog.Builder builderMapType = new AlertDialog.Builder(this);
        builderMapType.setTitle(getResources().getString(R.string.action_google_map_type));
        builderMapType.setSingleChoiceItems(googleMapTypeNames, selectedMapType,
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int item) {

                        if (item != selectedMapType) {
                            switchGoogleMapType(item);
                            // save selected type in settings
                            SharedPreferences preferences = PreferenceManager
                                    .getDefaultSharedPreferences(POIMapActivity.this);
                            SharedPreferences.Editor editor = preferences.edit();
                            editor.putString("googleMapType", String.valueOf(item));
                            editor.commit();
                        }
                        mapTypeDialog.dismiss();
                    }
                });
        mapTypeDialog = builderMapType.create();
        mapTypeDialog.show();

    } else if (id == R.id.action_legal_notices) {

        String licenseInfo = GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(getApplicationContext());
        AlertDialog.Builder licenseDialog = new AlertDialog.Builder(POIMapActivity.this);
        licenseDialog.setTitle(getString(R.string.action_legal_notices));
        licenseDialog.setMessage(licenseInfo);
        licenseDialog.show();

    } else if (id == R.id.action_scan_qr_code) {

        handleQRcodeScanRequest();

    } else if (id == R.id.action_about) {
        String about = getString(R.string.about_application);
        AlertDialog alertDialog;
        alertDialog = new AlertDialog.Builder(POIMapActivity.this).create();

        alertDialog.setTitle(getString(R.string.action_about));
        alertDialog.setMessage(Html.fromHtml(about));

        alertDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(R.string.ok),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                    }
                });
        alertDialog.show();
    }
    return super.onOptionsItemSelected(item);
}

From source file:bikebadger.RideFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Log.d(Constants.APP.TAG, "RideFragment.onCreate()");
    //setRetainInstance(true);

    mRideManager = RideManager.get(getActivity());
    Log.d(Constants.APP.TAG, "mRideManager set = RideManager.get(" + getActivity() + ")");

    setHasOptionsMenu(true);/*from ww w . j a  va  2  s.  c o  m*/

    // check for a Ride ID as an argument, and find the run
    Bundle args = getArguments();
    if (args != null) {
        long runId = args.getLong(ARG_RUN_ID, -1);
        Log.d(Constants.APP.TAG, "RideFragment.onCreate() runId=" + runId);
        if (runId != -1) {
            LoaderManager lm = getLoaderManager();
            lm.initLoader(LOAD_RUN, args, new RunLoaderCallbacks());
            lm.initLoader(LOAD_LOCATION, args, new LocationLoaderCallbacks());
        }
    }

    // Initialize the TextToSpeech Engine...
    // TODO this engine may not exist. Provide the ability to run without it.
    Intent checkTTSIntent = new Intent();
    checkTTSIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);

    if (checkTTSIntent.resolveActivity(mRideManager.mAppContext.getPackageManager()) != null) {
        startActivityForResult(checkTTSIntent, MY_DATA_CHECK_CODE_REQUEST);
    } else {
        Log.d(Constants.APP.TAG, "Could not find TTS Intent");
        MyToast.Show(getActivity(), "Could not find Text To Speech Service", Color.RED);
        AlertDialog ad1 = new AlertDialog.Builder(getActivity()).create();
        ad1.setCancelable(false);
        ad1.setTitle("Text To Speech Engine Not Found");
        ad1.setMessage(
                "There was a problem finding the Text To Speech Engine. Make sure it's install properly under Language and Input Settings.");
        ad1.setButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        ad1.show();

    }

    if (mRideManager.mLoadLastGPXFile) {
        Log.d(Constants.APP.TAG, "mLoadLastGPXFile=" + mRideManager.mLoadLastGPXFile);
        Log.d(Constants.APP.TAG, "mCurrentGPXPath=" + mRideManager.mCurrentGPXPath);

        OpenGPXFileOnNewThreadWithDialog(mRideManager.mCurrentGPXPath);
    }

    if (!mRideManager.IsGPSEnabled()) {
        ShowAlertMessageNoGps();
    }

    // keep the screen on so it doesn't time out and turn dark
    getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

}

From source file:org.loon.framework.android.game.LGameAndroid2DActivity.java

/**
 * ??Alter//w w  w  .j a  v  a2  s.c o  m
 * 
 * @param message
 */
public void showAndroidAlert(final String title, final String message) {
    Runnable showAlert = new Runnable() {
        public void run() {
            final AlertDialog alert = new AlertDialog.Builder(LGameAndroid2DActivity.this).create();
            alert.setTitle(title);
            alert.setMessage(message);
            alert.setButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    alert.dismiss();
                }
            });
            alert.show();
        }
    };
    runOnUiThread(showAlert);
}

From source file:bikebadger.RideFragment.java

public void onActivityResult(int requestCode, int resultCode, Intent data) {

    switch (requestCode) {
    case MY_DATA_CHECK_CODE_REQUEST:
        // for testing
        //resultCode = TextToSpeech.Engine.CHECK_VOICE_DATA_FAIL;
        switch (resultCode) {
        case TextToSpeech.Engine.CHECK_VOICE_DATA_PASS:
            RideManager.mTTS = new TextToSpeech(mRideManager.mAppContext, this);
            //RideManager.mTTS = null;
            Log.v(Constants.APP.TAG, "TextToSpeech installed");
            break;
        case TextToSpeech.Engine.CHECK_VOICE_DATA_BAD_DATA:
        case TextToSpeech.Engine.CHECK_VOICE_DATA_MISSING_DATA:
        case TextToSpeech.Engine.CHECK_VOICE_DATA_MISSING_VOLUME:
        case TextToSpeech.Engine.CHECK_VOICE_DATA_FAIL:

            Log.e(Constants.APP.TAG, "Got a failure. Text To Speech not available");

            AlertDialog ad = new AlertDialog.Builder(getActivity()).create();
            ad.setCancelable(false);//from  www . ja  v  a 2s  .c  om
            ad.setTitle("Text To Speech Engine Not Found");
            ad.setMessage(
                    "There was a problem finding the Text To Speech Engine. Make sure it's install properly under Language and Input Settings.");
            ad.setButton("Ok", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
            ad.show();

            // missing data, install it
            //Log.v(Constants.APP.TAG, "Need language stuff: " + resultCode);
            //Intent installIntent = new Intent();
            //installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
            //startActivity(installIntent);
            break;
        }

        break;
    /* No longer used as it is deprecated. Use SimpleFileDialog instead even though it blocks.
    TODO - integrate a slick open file that includes DropBox and Drive library!
    case Constants.APP.FILE_CHOOSER_REQUEST_CODE:
            
        if (resultCode == getActivity().RESULT_OK) {
            if (data != null) {
                // Get the URI of the selected file
                final Uri uri = data.getData();
                Log.i(Constants.APP.TAG, "Uri = " + uri.toString());
                try {
                    // Get the file path from the URI
                    final String path = FileUtils.getPath(mRideManager.mAppContext, uri);
                    //Toast.makeText(getActivity(), "File Selected: " + path, Toast.LENGTH_LONG).show();
                    OpenGPXFileOnNewThreadWithDialog(path);
                   // if(isVisible())
                     //    updateUI(); // update title bar file loaded
                } catch (Exception e) {
                    Log.e("FileSelectorTestActivity", "File select error", e);
                }
            }
        }
        break;
         */
    case Constants.APP.ACTION_WAYPOINT_REQUEST_CODE:
        if (resultCode == getActivity().RESULT_OK) {
            if (data != null) {
                final Location location = data.getParcelableExtra("location");
                String command = data.getStringExtra("command");
                final String arg = data.getStringExtra("argument");

                mRideManager.AddNewWaypoint(command, arg, location);
                // enable the save menu
                mMenu.findItem(R.id.menu_item_gpx_save).setEnabled(true);
            }
        }
        break;
    case MY_MAP_CODE_REQUEST:

        if (resultCode == getActivity().RESULT_OK) {
            Log.d(Constants.APP.TAG, "Return from map");
        }
        break;
    }

    super.onActivityResult(requestCode, resultCode, data);
}