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 ChildActivity extends AppCompatActivity { | |
@Override | |
public boolean onOptionsItemSelected(MenuItem item) { | |
int id = item.getItemId(); | |
if (id == android.R.id.home) { | |
NavUtils.navigateUpFromSameTask(this); | |
} | |
return super.onOptionsItemSelected(item); | |
} |
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
// implement LoaderManager.LoaderCallbacks<String> on MainActivity | |
public class MainActivity extends AppCompatActivity implements LoaderManager.LoaderCallbacks<String> { | |
// Create a constant int to uniquely identify loader | |
private static final int LOADER_ID = 101; | |
private static final String KEY = "key"; | |
@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 void onClickOpenAddressButton(View v) { | |
String address = "Cork Ireland"; | |
Uri.Builder builder = new Uri.Builder(); | |
builder.scheme("geo") | |
.path("0,0") | |
.appendQueryParameter("q", address); | |
Uri addressUri = builder.build(); | |
showMap(addressUri); |
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 openAnAppThatCanHandleThisIntent(Uri mapUri) { | |
Intent intent = new Intent(Intent.ACTION_VIEW); | |
if (intent.resolveActivity(getPackageManager()) != null) { | |
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
public final class NetworUtils { | |
private static final String BASE_URL = "https://api.example.com"; | |
private static final String FORMAT = "json"; | |
private static final String QUERY_PARAM = "q"; | |
private static final String SOME_OTHER_PARAM = "param"; | |
public static URL buildUrl(String queryParam, String someOtherParam) { | |
Uri constructUri = Uri.parse(BASE_URL).buildUpon() | |
.appendQueryParameter(QUERY_PARAM, queryParam) | |
.appendQueryParameter(SOME_OTHER_PARAM, someOtherParam) |
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 interface ListItemClickListener { | |
void onListItemClick(int clickedItemIndex); | |
} |
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
SELECT | |
TABLE_NAME, COLUMN_NAME, IS_NULLABLE | |
FROM INFORMATION_SCHEMA.COLUMNS | |
WHERE IS_NULLABLE = 'NO' |