Forked from: Cesar Díez (https://github.com/cesards)
* In titles means it has been categorized more than once (in different categories)
private File createFileFromInputStream(InputStream inputStream,String fileName) { | |
String path = ""; | |
File file = new File(Environment.getExternalStorageDirectory(), | |
"Files/"); | |
if (!file.exists()) { | |
if (!file.mkdirs()) | |
Log.d("Files", "Folder not created"); | |
else |
InputStream stream = mActivity.getResources().openRawResource(R.raw.file_name); |
public class CustomAdapter extends RecyclerView.Adapter<CustomAdapter.ViewHolder> | |
{ | |
private Context context; | |
// The items to display in your RecyclerView | |
private ArrayList<String> items; | |
// Allows to remember the last item shown on screen | |
private int lastPosition = -1; | |
public static class ViewHolder extends RecyclerView.ViewHolder |
public class Network { | |
public static DhcpInfo getNetworkInfo(Context context) { | |
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); | |
android.net.NetworkInfo activeNetworkInfo = cm.getActiveNetworkInfo(); | |
switch (activeNetworkInfo.getType()) { | |
case ConnectivityManager.TYPE_ETHERNET: | |
return null; | |
case ConnectivityManager.TYPE_WIFI: |
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<!-- Material Design Colors --> | |
<color name="md_red_50">#ffffebee</color> | |
<color name="md_red_100">#ffffcdd2</color> | |
<color name="md_red_200">#ffef9a9a</color> | |
<color name="md_red_300">#ffe57373</color> | |
<color name="md_red_400">#ffef5350</color> |
//get phone number | |
TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); | |
String imei = tm.getDeviceId(); | |
String tel = tm.getLine1Number(); |
Forked from: Cesar Díez (https://github.com/cesards)
* In titles means it has been categorized more than once (in different categories)
private void launchGoogleMaps(String name, String vicinity) { | |
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, | |
Uri.parse("http://maps.google.com/maps?q="+name+","+vicinity)); | |
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); // this is the magic | |
startActivity(intent); | |
} |
(EventBus) - Android optimized event bus that simplifies communication between Activities, Fragments, Threads, Services, etc. Less code, better quality.
An EventBus is a great tool for decoupling components in your application. Over the next few posts I will describe the ways that I have been using it to make my code cleaner, easier to read, and easier to test. But first, this week I want to discuss why I use an EventBus in the first place. In particular, I will compare its use to some alternative techniques.
VideoView videoView =(VideoView) findViewById(R.id.videoViewId); | |
Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getAbsolutePath()+"/yourvideo"); | |
videoView.setVideoURI(uri); | |
videoView.start(); |