View CreateMomentFragment.java
private int getLastImageId() {
final String[] imageColumns = {MediaStore.Images.Media._ID, MediaStore.Images.Media.DATA};
final String imageOrderBy = MediaStore.Images.Media._ID + " DESC";
Cursor imageCursor = getActivity().getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, imageColumns, null, null, imageOrderBy);
if (imageCursor.moveToFirst()) {
int id = imageCursor.getInt(imageCursor.getColumnIndex(MediaStore.Images.Media._ID));
String fullPath = imageCursor.getString(imageCursor.getColumnIndex(MediaStore.Images.Media.DATA));
Log.d(TAG, "getLastImageId::id " + id);
Log.d(TAG, "getLastImageId::path " + fullPath);
imageCursor.close();
View MapsAppDirection.java
//http://stackoverflow.com/questions/2662531/launching-google-maps-directions-via-an-intent-on-android
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr="+latitude_source+","+longitude_source+"&daddr="+latitude_dest+","+longitude_dest));
startActivity(intent);
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("google.navigation:q=an+address+city"));
View EditTextScrollView.java
//http://stackoverflow.com/questions/13812892/enable-scrollable-edittext-within-a-scrollview-and-viewflipper/13815747#13815747
EditText EtOne = (EditText) findViewById(R.id.EditText01);
EtOne.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (v.getId() == R.id.comment1) {
v.getParent().requestDisallowInterceptTouchEvent(true);
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_UP:
v.getParent().requestDisallowInterceptTouchEvent(false);
View EmailIntentWithAttachment.java
Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Payment Information");
emailIntent.putExtra(Intent.EXTRA_TEXT, stringBuilder.toString());
emailIntent.putExtra(Intent.EXTRA_EMAIL,
new String[] { emailValue });
ArrayList<Uri> uris = new ArrayList<Uri>();
// convert from paths to Android friendly Parcelable Uri's
Uri uri = null;
View DialogWIthLinkableText.java
final TextView tv = new TextView(this);
final SpannableString s = new SpannableString(response);
Linkify.addLinks(s, Linkify.WEB_URLS);
tv.setText(s);
tv.setMovementMethod(LinkMovementMethod.getInstance());
AlertDialog dialog = new AlertDialog.Builder(this)
.setPositiveButton(android.R.string.ok, null)
.setView(tv).create();
dialog.show();
View CreditCardValid.java
//http://rosettacode.org/wiki/Luhn_test_of_credit_card_numbers#Java
public static boolean isEmptyString(String stringValue) {
return stringValue == null || stringValue.trim().length() == 0;
}
public static boolean isCreditCardValid(String number) {
if (isEmptyString(number))
return false;
int s1 = 0, s2 = 0;
View fireexitfeed.json
[
{
"IsAddedByMe": true,
"IsFavorite": true,
"Latitude": 27.684554,
"LocationAddress": "test",
"LocationId": 6068,
"LocationImgUrl": "http://firesonar.blob.core.windows.net/checkinlocations/test.png",
"LocationName": "test",
"Longitude": 85.333882,
View ViewPagerCurrentFragment.java
Fragment fragment = (Fragment) mPagerAdapter.instantiateItem(mPager, mPager.getCurrentItem());
View DialogWithLinkText.java
final TextView tv = new TextView(this);
final SpannableString s = new SpannableString(result);
Linkify.addLinks(s, Linkify.WEB_URLS);
tv.setText(s);
tv.setMovementMethod(LinkMovementMethod.getInstance());
DialogFragment dg = new DialogFragment() {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
View DialogFragment.java
DialogFragment dg = new DialogFragment() {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
.setMessage(R.string.submit_confirm_message)
.setPositiveButton(R.string.submit_confirm_button, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
/*---THIS IS ADDED EXTRA--------*/
postInfoToServer();