这是调用函数
public class CameraActivity extends AppCompatActivity{
...
@Override
public void onPicture(byte[] bytes) {
mCapturingPicture = false;
mData=null;
mData=bytes;
final ByteBuffer buffer = ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN);
final int[] ints = new int[bytes.length / 4];
buffer.asIntBuffer().put(ints);
if ( mCameraView.mPreviewSize != null) {
Bitmap bitmap=Bitmap.createBitmap(ints,mCameraView.mPreviewSize.width,mCameraView.mPreviewSize.height,Bitmap.Config.ARGB_8888);
Intent intent = new Intent(CameraActivity.this, PicturePreviewActivity.class);
intent.putExtra("bitmap",bitmap);
startActivityForResult(intent,SAVE_PICTURE_OR_NOT);
}
这是Activitiy收到的电话
public class PicturePreviewActivity extends AppCompatActivity {
private String TAG ="Picture_Preview_Activity";
private static WeakReference<Bitmap> image;
private Button mSave;
private Button mDiscard;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG,"Picture Preview Activity onCreate");
setContentView(R.layout.activity_picture_preview);
final ImageView imageView = findViewById(R.id.image);
Bitmap bitmap=getIntent().getParcelableExtra("bitmap");
image=new WeakReference<>(bitmap);
这是清单
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".PicturePreviewActivity"
android:parentActivityName=".CameraActivity"/>
<activity
android:name=".CameraActivity"
android:hardwareAccelerated="true"
android:configChanges="orientation|screenLayout|keyboardHidden"
android:screenOrientation="landscape"
android:parentActivityName=".MainActivity"/>
Logcat显示接收到的活动尚未启动,但该应用未报告错误或崩溃。有人知道为什么会发生吗?我怀疑某些摄像头功能可能会阻止新活动启动,但哪个会阻止?