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.robpercival.locationdemo; | |
| import android.app.Activity; | |
| import android.content.Context; | |
| import android.location.Criteria; | |
| import android.location.Location; | |
| import android.location.LocationListener; | |
| import android.location.LocationManager; | |
| import android.os.Bundle; | |
| import android.util.Log; |
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 onPostExcute(String result){ // A Function to work in background and have the permission to change in UI simultaneously | |
| super.onPostExcute(result); | |
| try{ | |
| JSONObject jsonObject = new JSONObject(result); | |
| String weatherInfo = jsonObject.getString("weather"); | |
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
| import java.util.Arrays; | |
| import java.util.Pattern; | |
| import java.util.Matcher; | |
| public class HelloWorld { | |
| public static main (String[] args){ | |
| String mystring = "Mississippi"; | |
| String [] splitter = mystring.split("s"); // to split the phrase to words depends on a specific letter | |
| String riverPart = mystring.substring(2, 5); // to prints the letters starting from letter 2 to 5 "which is not including" |
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 DownloadTask extends AsyncTask<String, Void, String>{ | |
| @Override | |
| protected String doInBackground(String... urls){ | |
| String result = ""; // send Link to Method | |
| URL url; // initialize URL variable | |
| HttpURLConnection urlConnection = null; // initialize HttpURLConnection which later will be responsible for establishing Conn. | |
| try{ | |
| url = new URL(urls[0]); //calling (urls member) number 0 from the (String...) | |
| urlConnection = (HttpURLConnection).openConnection(); // initialize the connection to the URL | |
| InputStream in = urlConnection.getInputStream(); // connecting the HTML page to the input stream |
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
| final Handler handler = new Handler(); // A handler is a way used to run the code every certain delayed time | |
| Runnable run = new Runnable (){ // A Runnable is the that code | |
| @Override | |
| public void run (){ // An override fuction describe exactly the action to be taken within that time | |
| //Insert a code to be run every certain "delayed time" | |
| handler.postDelayed (this, 1000); // initialize the handler delayer for 1000msec= 1 second | |
| } | |
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
| ListView myList = (ListView) findViewById(R.id.mylist) | |
| ArrayList<String> myFamily = new ArrayList<String>(); | |
| myFamily.add("XXX"); // adding new items | |
| myFamily.add("YYY"); | |
| // OR ArrayList<String> myFamily = new ArrayList<String>(asList"XXX", "YYY"); | |
| ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.id.simple_list_item_1, myFamily); |
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
| // Insert the following lines below your package name | |
| import android.os.Bundle; | |
| import android.support.design.widget.FloatingActionButton; | |
| import android.support.design.widget.Snackbar; | |
| import android.support.v7.app.AppCompatActivity; | |
| import android.support.v7.widget.Toolbar; | |
| import android.view.View; | |
| import android.view.Menu; | |
| import android.view.MenuItem; |
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 MainActivity extends ActionBarActivity { | |
| class Number { | |
| double x; | |
| String message = ""; | |
| public void numTest() { | |
| { |
NewerOlder