多言語化
res/values/strings.xml - 英語
res/values-ja/strings.xml - 日本語
res/values-zh/strings.xml - 中国語(簡体)
res/values-zh-rTW/strings.xml - 中国語:台湾(繁體)
res/values-zh-rHK/strings.xml - 中国語:香港(繁體)
res/values-zh-rMO/strings.xml - 中国語:マカオ(繁體)
res/values-zh-rSG/strings.xml - 中国語:シンガポール(簡体)
2017年8月28日月曜日
Android 通知音
Android 通知音
RingtoneManager
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK && requestCode == 999) {
Uri uri = (Uri) data.getExtras().get(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
Ringtone ringtone = RingtoneManager.getRingtone(getActivity(), uri);
String name = ringtone.getTitle(getActivity());
System.out.println(name);
System.out.println(uri);
set_sound_url(id, uri.toString());
TextView select_Sound = (TextView) view.findViewById(R.id.select_sound);
select_Sound.setText(get_sound_url_title(id));
}
}
protected void lin2(String id) {
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, getString(R.string.select_sound_title));
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_ALARM);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, false);
startActivityForResult(intent, 999);
}
RingtoneManager
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK && requestCode == 999) {
Uri uri = (Uri) data.getExtras().get(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
Ringtone ringtone = RingtoneManager.getRingtone(getActivity(), uri);
String name = ringtone.getTitle(getActivity());
System.out.println(name);
System.out.println(uri);
set_sound_url(id, uri.toString());
TextView select_Sound = (TextView) view.findViewById(R.id.select_sound);
select_Sound.setText(get_sound_url_title(id));
}
}
protected void lin2(String id) {
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, getString(R.string.select_sound_title));
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_ALARM);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, false);
startActivityForResult(intent, 999);
}
ラベル:
Android
2017年7月31日月曜日
Android SoundPool soundPool
public class MainActivity extends AppCompatActivity {
protected SoundPool soundPool;
protected int id;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
test();
AssetManager am = getAssets();
try {
id = soundPool.load(am.openFd("PCM-M10_441kHz16bit.wav"), 1);
} catch (IOException e) {
e.printStackTrace();
}
soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
@Override
public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
Toast.makeText(MainActivity.this, "9999999999999", Toast.LENGTH_SHORT).show();
soundPool.play(id, 1, 1, 1, 1, 1);
}
});
}
protected void test() {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
SoundPool.Builder spb = new SoundPool.Builder();
AudioAttributes.Builder b = new AudioAttributes.Builder();
b.setUsage(AudioAttributes.USAGE_MEDIA);
b.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC);
AudioAttributes a = b.build();
spb.setAudioAttributes(a);
spb.setMaxStreams(12);
soundPool = spb.build();
}
}
}
2017年6月28日水曜日
android app中如何获取电源锁保持屏幕常亮
android app中如何获取电源锁保持屏幕常亮
protected void screen_on() {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
protected void screen_off() {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
ラベル:
Android_Layout
2017年6月26日月曜日
Java Timer
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static int x;
public static void main(String[] args) throws Exception {
x = 30 * 60 + 9;
System.out.println(x);
while(x != 0){
x = x -1;
show();
}
}
public static void show(){
int hh = x /60;
int ss = x - hh * 60;
int hht1 = hh % 100 /10;
int hht2 = hh % 10;
int sst1 = ss % 100 /10;
int sst2 = ss % 10;
System.out.println("--------------");
System.out.print(hht1);
System.out.print(hht2);
System.out.print(sst1);
System.out.println(sst2);
System.out.println("--------------");
}
}
import java.io.InputStreamReader;
public class Main {
public static int x;
public static void main(String[] args) throws Exception {
x = 30 * 60 + 9;
System.out.println(x);
while(x != 0){
x = x -1;
show();
}
}
public static void show(){
int hh = x /60;
int ss = x - hh * 60;
int hht1 = hh % 100 /10;
int hht2 = hh % 10;
int sst1 = ss % 100 /10;
int sst2 = ss % 10;
System.out.println("--------------");
System.out.print(hht1);
System.out.print(hht2);
System.out.print(sst1);
System.out.println(sst2);
System.out.println("--------------");
}
}
https://paiza.io/projects/FJ_pxjUT07pv51Ab7TWA4w
2017年6月4日日曜日
android 屏幕旋转
android 屏幕旋转
android:screenOrientation="portrait">
纵向方向(显示的高度大于宽度)。
https://developer.android.com/guide/topics/manifest/activity-element.html
ラベル:
Android_Layout
2017年6月2日金曜日
android Bitmap to File
android Bitmap to File
case REQUEST_IMAGE_CAPTURE:
File f = getFilesDir();
Bitmap bit = data.getExtras().getParcelable("data");
ImageView imageView = (ImageView) findViewById(R.id.bit);
imageView.setImageBitmap(bit);
try {
FileOutputStream fileOutputStream = new FileOutputStream(f.getPath() + "/xxx.jpg");
bit.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream);
fileOutputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
break;
case REQUEST_IMAGE_CAPTURE:
File f = getFilesDir();
Bitmap bit = data.getExtras().getParcelable("data");
ImageView imageView = (ImageView) findViewById(R.id.bit);
imageView.setImageBitmap(bit);
try {
FileOutputStream fileOutputStream = new FileOutputStream(f.getPath() + "/xxx.jpg");
bit.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream);
fileOutputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
break;
登録:
投稿 (Atom)