This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ReviveServiceAlarmManagerBroadcastReceiver extends | |
BroadcastReceiver { | |
Context temp_context; | |
final public static String SINGLE_TIME = "onetime"; | |
// static int TIME_INTERVAL_FOR_NETWORK_LOCATIONS = 2; | |
DatabaseHelper myDatabase; | |
@Override | |
public void onReceive(final Context context, Intent intent) { | |
temp_context = context; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SimpleCustomAdapter extends SimpleAdapter { | |
private int[] colors = new int[] { 0x30FFFFFF, 0x30ccffcc }; | |
Context context; | |
DatabaseHelper myDatabase; | |
public SimpleCustomAdapter(Context context, | |
List<HashMap<String, String>> items, int resource, String[] from, | |
int[] to) { | |
super(context, items, resource, from, to); | |
this.context = context; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I forked this code from- http://www.piwai.info/chatheads-basics/ | |
// Chat head is displayed from a service. | |
// uses a permission: <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> | |
// This is a service so it needs to be declared in manifest: <service android:name=".ChatHeadService" /> | |
// Whenever you need to display the chat head, just start the service | |
// example: startService(new Intent(context, ChatHeadService.class)); | |
public class ChatHeadService extends Service { | |
private WindowManager windowManager; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Handler handler = new Handler(); | |
handler.postDelayed(new Runnable() { | |
public void run() { | |
//your code here- to be executed after delay | |
} | |
}, 2000); //2000 is 2 seconds here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Geocoder geocoder; | |
List<Address> addresses; | |
geocoder = new Geocoder(this, Locale.getDefault()); | |
String address = ""; | |
try { | |
addresses = geocoder.getFromLocation(latitude, | |
longitude, 1); | |
address = addresses.get(0).getAddressLine(0); | |
Log.e("address", address); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SimpleDateFormat fromUser = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); | |
SimpleDateFormat myFormat = new SimpleDateFormat("MMM d, ''yy"); | |
try { | |
String reformattedStr = myFormat.format(fromUser | |
.parse("2013-09-12 09:09:09")); | |
CustomLog.logBlack(Thread.currentThread().getStackTrace(), | |
reformattedStr); | |
} catch (Exception e) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ayushhgoyal.custom; | |
import android.util.Log; | |
public class CustomLog { | |
public static void logRed(StackTraceElement[] stackTraceElements, String msg) { | |
Log.e(stackTraceElements[2].getClassName().substring( | |
stackTraceElements[2].getClassName().lastIndexOf(".") + 1) | |
+ "." | |
+ stackTraceElements[2].getMethodName() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/toast_layout_root" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent" | |
android:background="#FFFFFF" | |
android:orientation="horizontal" | |
android:padding="8dp" > | |
<TextView |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LoginUser extends AsyncTask<String, Integer, String> { | |
HttpClient client = new DefaultHttpClient(); | |
JSONObject json; | |
ArrayList<NameValuePair> params = new ArrayList<NameValuePair>(); | |
final static String URL = "http://www.your-url-here.com"; | |
@Override | |
protected String doInBackground(String... params) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.horizontalswipe; | |
import android.app.Activity; | |
import android.content.Context; | |
import android.os.Bundle; | |
import android.util.Log; | |
import android.view.GestureDetector; | |
import android.view.GestureDetector.OnGestureListener; | |
import android.view.MotionEvent; | |
import android.widget.ImageView; |