You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.0 KiB
Java
71 lines
2.0 KiB
Java
2 years ago
|
package com.xinyingpower.microphoto;
|
||
|
|
||
|
import android.content.Intent;
|
||
|
import android.os.Build;
|
||
|
import android.os.Environment;
|
||
|
import android.support.v7.app.AppCompatActivity;
|
||
|
import android.os.Bundle;
|
||
|
import android.view.View;
|
||
|
import android.widget.TextView;
|
||
|
|
||
|
import com.dowse.camera.client.DSCameraManager;
|
||
|
import com.xinyingpower.microphoto.databinding.ActivityMainBinding;
|
||
|
|
||
|
import java.io.File;
|
||
|
|
||
|
public class MainActivity extends AppCompatActivity {
|
||
|
|
||
|
// Used to load the 'microphoto' library on application startup.
|
||
|
static {
|
||
|
System.loadLibrary("microphoto");
|
||
|
}
|
||
|
|
||
|
private ActivityMainBinding binding;
|
||
|
|
||
|
@Override
|
||
|
protected void onCreate(Bundle savedInstanceState) {
|
||
|
super.onCreate(savedInstanceState);
|
||
|
|
||
|
binding = ActivityMainBinding.inflate(getLayoutInflater());
|
||
|
setContentView(binding.getRoot());
|
||
|
|
||
|
Intent intent = new Intent(getApplicationContext(), MicroPhotoService.class);
|
||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||
|
startForegroundService(intent);
|
||
|
} else {
|
||
|
startService(intent);
|
||
|
}
|
||
|
|
||
|
// Example of a call to a native method
|
||
|
TextView tv = binding.sampleText;
|
||
|
tv.setText(stringFromJNI());
|
||
|
|
||
|
this.binding.button.setOnClickListener(new View.OnClickListener() {
|
||
|
@Override
|
||
|
public void onClick(View view) {
|
||
|
File path = Environment.getExternalStorageDirectory();
|
||
|
File file = new File(path, "photo.jpg");
|
||
|
boolean res = false;
|
||
|
|
||
|
res = DSCameraManager.getInstace().init();
|
||
|
|
||
|
res = DSCameraManager.getInstace().takePhoto(file.getAbsolutePath(), 1);
|
||
|
|
||
|
if (!res)
|
||
|
{
|
||
|
int aa = 0;
|
||
|
}
|
||
|
|
||
|
res = DSCameraManager.getInstace().unInit();
|
||
|
|
||
|
}
|
||
|
});
|
||
|
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* A native method that is implemented by the 'microphoto' native library,
|
||
|
* which is packaged with this application.
|
||
|
*/
|
||
|
public native String stringFromJNI();
|
||
|
}
|