0

我有一个扩展应用程序的类,从那里开始,在检测抖动时,它应该打开一个活动。但是,对于特定的活动,它会关闭应用程序。日志中没有崩溃或错误,这使得调试变得非常困难......

启动活动的代码如下:

                int currentViewingMemberId = CommonFunctions.get_CURRENT_VIEWING_MEMBER_ID(this);
                Bitmap b = takeScreenshot();
                Intent contactAndReportIntent = ReportIssueActivity.getIntentForActivity(getApplicationContext(), true, null, b, currentViewingMemberId);
                contactAndReportIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(contactAndReportIntent);

                mSensorManager.unregisterListener(this);
                hasAccelerometerSensorBeenRegistered = false;

getIntentForActivity() 方法如下:

public static Intent getIntentForActivity(Context context, boolean isFromShake, String helpTip, Bitmap screenshot, int currentViewingMemberId) {
        Intent intent = new Intent(context, ReportIssueActivity.class);
        intent.putExtra(FROM_SHAKE, isFromShake);
        if (helpTip == null) {
            helpTip = "";
        }
        if (screenshot != null) {
            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            screenshot.compress(Bitmap.CompressFormat.PNG, 100, stream);
            byte[] byteArray = stream.toByteArray();
            intent.putExtra(SCREENSHOT_IMAGE, byteArray);
        }
        intent.putExtra(HELP_TIP, helpTip);
        intent.putExtra(CURRENT_VIEWING_MEMBER_ID, currentViewingMemberId);
        return intent;
    }

takeScreenshot() 捕获当前窗口并成功返回一个位图,但甚至没有调用 Activity onCreate()。

任何想法都会有所帮助,谢谢!:)

4

1 回答 1

0

事实证明,当我试图返回我的活动意图时,我得到了一个 TransactionTooLargeException。交换:

 screenshot.compress(Bitmap.CompressFormat.PNG, 100, stream);

为了:

 screenshot.compress(Bitmap.CompressFormat.JPEG, 80, stream);

修复它,因为它将屏幕截图图像大小减小到允许的数量以下。

于 2018-05-08T13:46:17.967 回答