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 list = new ArrayList<>(); | |
while(cursor.moveToNext()) { | |
String column1 = cursor.getString( | |
cursor.getColumnIndexOrThrow(FeedEntry.COLUMN_COLUMN1)); | |
list.add(column1); | |
} | |
cursor.close(); |
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
public void read (DatabaseHelper mDbHelper) { | |
SQLiteDatabase db = mDbHelper.getReadableDatabase(); | |
// Define which rows you want to query | |
String[] projection = { | |
FeedEntry._ID, | |
FeedEntry.COLUMN_NAME1, | |
FeedEntry.COLUMN_NAME2 | |
}; |
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
public final class FeedReaderContract { | |
//Inner class that defines the table contents | |
public static class FeedEntry implements BaseColumns { | |
public static final String TABLE_NAME = "table"; | |
public static final String COLUMN_NAME_1 = "colums1"; | |
public static final String COLUMN_NAME_2 = "column2"; | |
} | |
} |
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
class MyThread extends Thread { | |
MyThread (String thrdName) { | |
super(thrdName); //constructor | |
start(); //starts the thread | |
} | |
//run() is the only method that you must override | |
public void run() { | |
System.out.println(getName() + " starting."); |
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
In Thread#3 count is 1229 | |
In Thread#2 count is 619 | |
In Thread#3 count is 1230 | |
In Thread#1 count is 620 | |
In Thread#3 count is 1231 | |
In Thread#2 count is 620 | |
In Thread#3 count is 1232 | |
In Thread#1 count is 621 | |
In Thread#3 count is 1233 | |
In Thread#2 count is 621 |
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
class MyThread implements Runnable { | |
Thread thrd; | |
MyThread (String thrdName) { | |
thrd = new Thread(this, thrdName); //constructor | |
thrd.start(); //starts the thread | |
} | |
//run() is the only method that you must override | |
public void run() { |
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
AudioManager.OnAudioFocusChangeListener afChangeListener = | |
new AudioManager.OnAudioFocusChangeListener() { | |
public void onAudioFocusChange(int focusChange) { | |
if (focusChange == AudioManager.AUDIOFOCUS_LOSS) { | |
// Permanent loss of audio focus | |
mMediaPlayer.stop(); | |
} | |
else if (focusChange == AUDIOFOCUS_LOSS_TRANSIENT) { | |
// Pause playback | |
mMediaPlayer.pause(); |
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
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); | |
AudioManager.OnAudioFocusChangeListener afChangeListener; | |
audioManager.abandonAudioFocus(afChangeListener); |
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
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); | |
AudioManager.OnAudioFocusChangeListener afChangeListener; | |
int res = audioManager.requestAudioFocus(afChangeListener, AudioManager.STREAM_MUSIC, // Music streaming | |
AudioManager.AUDIODOCUS_GAIN); // Permanent focus | |
if(res == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) { | |
// Play the audio | |
} |
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
if(viewSwitcher.getCurrentView() == ratingBar) { | |
viewSwitcher.showNext();//if the current view is the RatingBar, then show | |
//the next one, which is the TextView | |
textView.setText(ratingBarResult + " / 10.0"); |