This file contains 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
ArrayList<String> words = new ArrayList<String>(); | |
words.add("One"); | |
//Find the rootView of Numbers activity | |
LinearLayout rootView = findViewById(R.id.rootView); | |
//Create a TextView programmatically | |
TextView wordView = new TextView(this); | |
//Show first element of the ArrayList ib that TextView | |
wordView.setText(words.get(0)); | |
//Attach TextView with the rootView |
This file contains 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
/** | |
* Convert the {@link InputStream} into a String which contains the | |
* whole JSON response from the server. | |
*/ | |
private static String readFromStream(InputStream inputStream) throws IOException { | |
StringBuilder output = new StringBuilder(); | |
if (inputStream != null){ | |
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, Charset.forName("UTF-8")); | |
BufferedReader reader = new BufferedReader(inputStreamReader); |
This file contains 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
ConnectivityManager connectivityManager = (ConnectivityManager) | |
getSystemService(Context.CONNECTIVITY_SERVICE); | |
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); | |
if(networkInfo != null && networkInfo.isConnected()){ | |
// TODO: Do sothing here if the user is Connected to the INTERNET | |
} else { | |
// TODO: Do sothing here if the user is not connected to the INTERNET | |
} |
This file contains 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
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); | |
ClipData clip = ClipData.newPlainText(label, text); | |
clipboard.setPrimaryClip(clip); | |
// Make sure you have imported android.content.ClipboardManager and NOT android.text.ClipboardManager. Latter is deprecated. |