Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 尝试使用和附件发送邮件时Gmail崩溃_Java_Android_Gmail - Fatal编程技术网

Java 尝试使用和附件发送邮件时Gmail崩溃

Java 尝试使用和附件发送邮件时Gmail崩溃,java,android,gmail,Java,Android,Gmail,试图录制音频,然后用GMAIL应用程序发送,但它会粉碎并告知空指针异常,诸如此类,请参见下图。 我正试图在5秒钟内录制,然后停止计时器并发送电子邮件 还有我的代码: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); outputFile = En

试图录制音频,然后用GMAIL应用程序发送,但它会粉碎并告知空指针异常,诸如此类,请参见下图。 我正试图在5秒钟内录制,然后停止计时器并发送电子邮件

还有我的代码:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    outputFile = Environment.getExternalStorageDirectory().
            getAbsolutePath() + "/recordMemo.3gp";

    eDB = new dbConfig(this);
    sqlDB = eDB.getWritableDatabase();

    smsPreferences = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
    smsText = smsPreferences.getString("smsTXT", "I'll call you later");
    Log.d("TEXT", smsText);

    gpsManager = new GPSManager();

    gpsManager.startListening(getApplicationContext());
    gpsManager.setGPSCallback((GPSCallback) this);


    StateListener phoneStateListener = new StateListener();
    telephonymanager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
    telephonymanager.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);

    myRecorder = new MediaRecorder();
    myRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    myRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
    myRecorder.setAudioEncoder(MediaRecorder.OutputFormat.AMR_NB);
    myRecorder.setOutputFile(outputFile);

    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
                .add(R.id.container, new PlaceholderFragment())
                .commit();
    }

    //gpsInfo = (TextView) findViewById(R.id.gps_info);
    //gpsInfo.setText(getString(R.string.gpsSPEED));

    //

}

CountDownTimer start = new CountDownTimer(5000, 1000) {

                        @Override
                        public void onTick(long l) {
                            //Toast.makeText(getApplicationContext(), "Recording!!!",
                            //        Toast.LENGTH_SHORT).show();

                        }

                        @Override
                        public void onFinish() {
                            try {
                                myRecorder.stop();
                                myRecorder.release();
                                myRecorder = null;

                                Log.d("STOP", "STOP");

                                Toast.makeText(getApplicationContext(), "Stop recording...",
                                        Toast.LENGTH_SHORT).show();

                            } catch (IllegalStateException e) {
                                e.printStackTrace();
                            }
                            catch (RuntimeException e) {
                                e.printStackTrace();
                            }

                            if (action.equals("1")) {
                                //Log.d("OUTPUT", outputFile);

                                Intent share = new Intent(Intent.ACTION_SEND);
                                share.setType("application/octet-stream");

                                share.putExtra(Intent.EXTRA_SUBJECT, "My Memo");
                                share.putExtra(Intent.EXTRA_TEXT, "Sending my memo");
                                share.putExtra(Intent.EXTRA_EMAIL,
                                        new String[] { myEmail });

                                share.putExtra(Intent.EXTRA_STREAM,Uri.parse("file://" + outputFile));
                                MainActivity.this.startActivity(share);
                            }

                        }
                    }.start();

什么是myEmail?它是空的吗?@greenapps否它有一个电子邮件字符串。一切正常,直到我点击gmail应用程序中的发送按钮。