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
protected void exitApp() { | |
// force close app | |
android.os.Process.killProcess(android.os.Process.myPid()); | |
} |
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 static int dpToPx(int dp) | |
{ | |
return (int) (dp * Resources.getSystem().getDisplayMetrics().density); | |
} | |
public static int pxToDp(int px) | |
{ | |
return (int) (px / Resources.getSystem().getDisplayMetrics().density); | |
} |
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
//http://unicode-table.com/es/ | |
String message = "esto es un "+'\u0022'+"hola"+'\u0022'; | |
System.out.println("message "+message); | |
Log.i("CONSOLE", "message "+message); | |
//output | |
message esto es un "hola" |
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
// http://jakewharton.github.io/butterknife/ | |
//activity | |
public class MyActivity extends Activity | |
{ | |
@InjectView(R.id.ibuClose) ImageButton ibuClose; | |
@InjectView(R.id.lviMyAlerts) ListView lviMyAlerts; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) | |
{ |
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 MyLoader extends AsyncTaskLoader<String> { | |
boolean isLoading = false; | |
String result =null; | |
public PromotionsLoader(Context context) | |
{ | |
super(context); | |
connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); |
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
@Override | |
public String loadInBackground() { | |
if(NetworkConnectivityUtils.hasNetworkConnectivity(connectivityManager)) | |
{ | |
MyEntity entity = new MyEntity(); | |
Gson gson = new Gson(); | |
String json = gson.toJson(entity); | |
request = new SoapObject(NAMESPACE, METHOD_NAME); |
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 static void launchGoogleMaps(Context context, double latitude, double longitude) { | |
String coordinates = "http://maps.google.com/maps?daddr=" + latitude + "," + longitude; | |
Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse(coordinates) ); | |
context.startActivity(intent ); | |
} |
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
private void populateData() | |
{ | |
MyAdapter adapter= new MyAdapter(getActivity(),reqMyEntityList); | |
lviRequest.setAdapter(adapter); | |
lviRequest.setOnItemClickListener(new AdapterView.OnItemClickListener() { | |
@Override | |
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { | |
MyEntity myEntity= (MyEntity)adapterView.getAdapter().getItem(i); | |
gotoActivity(myEntity); |
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
private void changeFragment(Bundle args, int content, Fragment fragment, String tag) | |
{ | |
if (args != null) fragment.setArguments(args); | |
FragmentManager fragmentManager = getSupportFragmentManager(); | |
fragmentManager.beginTransaction().replace(content, fragment, tag).commit(); | |
} |
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
private String mParam1; | |
private int mParam2; | |
public void loadData() { | |
if (getArguments() != null) { | |
mParam1 = getArguments().getString("MYSTRING"); | |
mParam2 = getArguments().getInt("MYINT"); | |
} | |
} |