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
@Override | |
public boolean onCreateOptionsMenu(Menu menu) { | |
getMenuInflater().inflate(R.menu.search, menu); | |
final MenuItem item = menu.findItem(R.id.search); | |
if (item != null) { | |
final View actionView = item.getActionView(); | |
if (actionView != null) { | |
SearchView searchView = (SearchView) actionView; |
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
<menu xmlns:tools="http://schemas.android.com/tools" | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto"> | |
<item | |
android:id="@+id/search" | |
android:title="@string/my_title" | |
app:actionViewClass="android.widget.SearchView" | |
android:showAsAction="always" | |
app:showAsAction="always" |
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
final String packageName = getPackageName(); | |
Uri alarmSound = Uri.parse("android.resource://" + packageName + "/" + R.raw.my_audio); | |
MediaPlayer mp = new MediaPlayer(); | |
mp.setDataSource(this, alarmSound); | |
mp.setAudioStreamType(AudioManager.STREAM_ALARM); | |
mp.prepare(); | |
mp.start(); | |
AudioManager mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); |
NewerOlder