AndroidDeviceMonitor 打不开 data 文件夹
好像更AndroidImage有关。
2017年3月13日月曜日
2017年3月12日日曜日
intent Camera
intent Camera
protected void t1() {
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 1);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
ImageView imageView = (ImageView) findViewById(R.id.imageView);
Bundle bu = data.getExtras();
Bitmap bt = (Bitmap) bu.get("data");
imageView.setImageBitmap(bt);
}
https://developer.android.com/training/camera/photobasics.html
static final int REQUEST_IMAGE_CAPTURE = 1;
private void dispatchTakePictureIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
mImageView.setImageBitmap(imageBitmap);
}
}
protected void t1() {
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 1);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
ImageView imageView = (ImageView) findViewById(R.id.imageView);
Bundle bu = data.getExtras();
Bitmap bt = (Bitmap) bu.get("data");
imageView.setImageBitmap(bt);
}
https://developer.android.com/training/camera/photobasics.html
static final int REQUEST_IMAGE_CAPTURE = 1;
private void dispatchTakePictureIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
mImageView.setImageBitmap(imageBitmap);
}
}
2017年3月6日月曜日
Android 的第一款軟體誕生
Android 的第一款軟體誕生。利用了Flickr提供的圖片查詢API按照名稱
查詢圖片,並顯示在手機上。
2016年5月開始接觸JAVA, 本軟體是邊學邊用的結果。
下一款軟體爭取能夠公開在GooglePlay上。
下載地址
app-free-release.apk
https://www.asuswebstorage.com/navigate/s/181301E935CB4FD480EB2D54B763A9A9Y
查詢圖片,並顯示在手機上。
2016年5月開始接觸JAVA, 本軟體是邊學邊用的結果。
下一款軟體爭取能夠公開在GooglePlay上。
下載地址
app-free-release.apk
https://www.asuswebstorage.com/navigate/s/181301E935CB4FD480EB2D54B763A9A9Y
2017年2月28日火曜日
Java CallBack 练习
Java CallBack 练习
https://paiza.io/projects/J4kb3mqHFWTylgPFh_q-sw
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws Exception {
Text1 tt1 = new Text1();
tt1.t1(new Text1.CallBack(){
public void gets(String x){
System.out.println(x);
}
public void gety(String y){
System.out.println(y);
}
});
}
}
class Text1{
interface CallBack{
public void gets(String x);
public void gety(String y);
}
public void t1( CallBack cb){
int i = 6;
for(; i < 200; i++){
}
if(i%2 == 0){
cb.gets("x" + i + "");
}else{
cb.gety("y" + i + "");
}
}
}
https://paiza.io/projects/J4kb3mqHFWTylgPFh_q-sw
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws Exception {
Text1 tt1 = new Text1();
tt1.t1(new Text1.CallBack(){
public void gets(String x){
System.out.println(x);
}
public void gety(String y){
System.out.println(y);
}
});
}
}
class Text1{
interface CallBack{
public void gets(String x);
public void gety(String y);
}
public void t1( CallBack cb){
int i = 6;
for(; i < 200; i++){
}
if(i%2 == 0){
cb.gets("x" + i + "");
}else{
cb.gety("y" + i + "");
}
}
}
2017年2月25日土曜日
Android AdMob広告
Android AdMob広告
build.gradle
dependencies {
...
implementation 'com.google.android.gms:play-services-ads:11.8.0'
}
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
protected void admo() {
// xmlns:ads="http://schemas.android.com/apk/res-auto"
ViewGroup viewGroup = (ViewGroup) findViewById(R.id.activity_main);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
AdView adView = new AdView(this);
adView.setBackgroundColor(ContextCompat.getColor(this, R.color.colorAccent));
adView.setLayoutParams(layoutParams);
layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId("ca-app-pub-3940256099942544/6300978111");
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
viewGroup.addView(adView);
}
https://developers.google.com/admob/android/banner
Set Up Google Play Services
https://developers.google.com/android/guides/setup
AdRequest.Builder adRequest = new AdRequest.Builder();
adRequest.addTestDevice("7026FA2EC1DC7E60FBEA02C64D33BD8B"); //asus
adRequest.addTestDevice("53185CF5BFA5B2121DF7FA86E7064C22"); //huawei
adView.loadAd(adRequest.build());
<manifest>
<application>
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="[ADMOB_APP_ID]"/>
</application>
</manifest>
public class MainActivity extends AppCompatActivity {
...
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
MobileAds.initialize(this, "YOUR_ADMOB_APP_ID");
}
...
}
https://developers.google.com/admob/android/test-ads
Enable test devices
build.gradle
dependencies {
...
implementation 'com.google.android.gms:play-services-ads:11.8.0'
}
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
protected void admo() {
// xmlns:ads="http://schemas.android.com/apk/res-auto"
ViewGroup viewGroup = (ViewGroup) findViewById(R.id.activity_main);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
AdView adView = new AdView(this);
adView.setBackgroundColor(ContextCompat.getColor(this, R.color.colorAccent));
adView.setLayoutParams(layoutParams);
layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId("ca-app-pub-3940256099942544/6300978111");
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
viewGroup.addView(adView);
}
https://developers.google.com/admob/android/banner
Set Up Google Play Services
https://developers.google.com/android/guides/setup
AdRequest.Builder adRequest = new AdRequest.Builder();
adRequest.addTestDevice("7026FA2EC1DC7E60FBEA02C64D33BD8B"); //asus
adRequest.addTestDevice("53185CF5BFA5B2121DF7FA86E7064C22"); //huawei
adView.loadAd(adRequest.build());
<manifest>
<application>
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="[ADMOB_APP_ID]"/>
</application>
</manifest>
public class MainActivity extends AppCompatActivity {
...
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
MobileAds.initialize(this, "YOUR_ADMOB_APP_ID");
}
...
}
https://developers.google.com/admob/android/test-ads
Enable test devices
2017年2月24日金曜日
Android MediaPlayer
Android MediaPlayer
protected void t1() {
try {
String url = "http://www.ne.jp/asahi/music/myuu/wave/menuettm.mp3";
// Uri mu = Uri.parse("http://www.ne.jp/asahi/music/myuu/wave/menuettm.mp3");
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_RING);
// mediaPlayer.setDataSource(getApplicationContext(), mu);
mediaPlayer.prepare();
mediaPlayer.start();
mediaPlayer.setDataSource(url);
} catch (IOException e) {
e.printStackTrace();
}
}
protected void t1() {
try {
String url = "http://www.ne.jp/asahi/music/myuu/wave/menuettm.mp3";
// Uri mu = Uri.parse("http://www.ne.jp/asahi/music/myuu/wave/menuettm.mp3");
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_RING);
// mediaPlayer.setDataSource(getApplicationContext(), mu);
mediaPlayer.prepare();
mediaPlayer.start();
mediaPlayer.setDataSource(url);
} catch (IOException e) {
e.printStackTrace();
}
}
2017年2月7日火曜日
登録:
投稿 (Atom)