Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/67.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 邮件发件人活动:无法启动活动ComponentInfo和资源$NotFound异常_Java_Android_Ftp Client - Fatal编程技术网

Java 邮件发件人活动:无法启动活动ComponentInfo和资源$NotFound异常

Java 邮件发件人活动:无法启动活动ComponentInfo和资源$NotFound异常,java,android,ftp-client,Java,Android,Ftp Client,我正在开发一个将图片发送到url的应用程序。当前,当我将应用程序发送到MailSenderActivity java类时,我遇到了一个问题。每次运行它时,我都会收到一个错误,该错误表示我有未找到异常的资源。我试图在我的代码中通过有根据的猜测和注释部分找到这个错误的根源,但我无法找到错误的根源或解决方案。欢迎任何帮助。我已经添加了我的LogCat、java类和清单 MailSenderActivity类 import android.location.Location; import androi

我正在开发一个将图片发送到url的应用程序。当前,当我将应用程序发送到MailSenderActivity java类时,我遇到了一个问题。每次运行它时,我都会收到一个错误,该错误表示我有未找到异常的资源。我试图在我的代码中通过有根据的猜测和注释部分找到这个错误的根源,但我无法找到错误的根源或解决方案。欢迎任何帮助。我已经添加了我的LogCat、java类和清单

MailSenderActivity类

import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.Toast;
import android.widget.EditText;
import android.telephony.TelephonyManager;

public class MailSenderActivity extends Activity implements OnClickListener {
    public String subj;
    public String body;
    public String from;
    public String toList;
    public String ptName;
    public String ptDesc;
    public String ptType;
    public String ptURL;
    private String ptURL_noFTP;
    private String ptLat;
    private String ptLng;
    private String item_sep;
    private Context c;
    private Button send;
    private Button button_return;
    private MailSenderActivity self = this;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        c = super.getApplicationContext();
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        body = "Body.";
        /*ptLat = Globals.lat;
        ptLng = Globals.lng;
        final LocationManager mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        final LocationListener mlocListener = new MyLocationListener();
        mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
                (long) 2000, (float) 1.0, mlocListener); // (provider,*/
                                                            // time
                                                            // (ms),
                                                            // distance
                                                            // (m),
                                                            // listener)
        Intent thisIntent = getIntent();
        ptType = thisIntent.getStringExtra("Type");
        ptURL = "urlIsHere"
                + thisIntent.getStringExtra("Filename");

        ptURL_noFTP = "urlIsHere"
                + thisIntent.getStringExtra("Filename");
        ptName = thisIntent.getStringExtra("Filename");
        setContentView(R.layout.mail_prep_apv);
        setLayout(ptType);
        send = (Button) findViewById(R.id.Send);
        send.setOnClickListener(this);
    }

    public void onClick(View v) {
        switch (v.getId()) {
        case (R.id.Send):
            InputMethodManager inputManager = (InputMethodManager) c
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            inputManager.hideSoftInputFromWindow(this.getCurrentFocus()
                    .getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
            from = "email";
            toList = "email";
            EditText etName = (EditText) findViewById(R.id.pointName);
            ptName = etName.getText().toString();
            EditText etDesc = (EditText) findViewById(R.id.pointDesc);
            ptDesc = etDesc.getText().toString();
            item_sep = getResources().getString(R.string.item_separator);
            subj = "POINT: " + ptName + item_sep + /*ptLat +*/ item_sep /*+ ptLng*/
                    + item_sep + ptType + item_sep + ptDesc;
            new MyAsyncTask(this).execute();
            setContentView(R.layout.sent);
            button_return = (Button) findViewById(R.id.Return);
            button_return.setOnClickListener(self);
            break;
        case (R.id.Return):
            send.setClickable(true);
            finish();
            break;
        }
    }

    public void setLayout(String type) {
        if (type.equals(getResources().getString(R.string.type_comment)))
            setContentView(R.layout.mail_prep_comment);
        else if (type.equals(getResources().getString(R.string.type_android))) {
            setContentView(R.layout.mail_prep_android);
            /*EditText pointName = (EditText) findViewById(R.id.pointName);
            TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
            pointName.setText(telephonyManager.getDeviceId());*/
        } else if (type.equals(getResources().getString(R.string.type_audio))
                || type.equals(getResources().getString(R.string.type_picture))
                || type.equals(getResources().getString(R.string.type_video))) {
            setContentView(R.layout.mail_prep_apv);
            EditText pointDesc = (EditText) findViewById(R.id.pointDesc);
            pointDesc.setText(ptURL_noFTP);
            EditText pointName = (EditText) findViewById(R.id.pointName);
            pointName.setText(ptName);
        }
    }

    /*private class MyLocationListener implements LocationListener {
        public void onLocationChanged(Location loc) {
            Toast.makeText(c, "Getting Location.", Toast.LENGTH_SHORT).show();
            ptLat = "" + loc.getLatitude();
            ptLng = "" + loc.getLongitude();
        }

        public void onProviderDisabled(String provider) {
            Toast.makeText(c, "GPS Disabled", Toast.LENGTH_SHORT).show();
        }

        public void onProviderEnabled(String provider) {
            Toast.makeText(c, "GPS Enabled", Toast.LENGTH_SHORT).show();
        }

        public void onStatusChanged(String provider, int status, Bundle extras) {
        }
    }*/

    public void onBackPressed() {
        setResult(Activity.RESULT_CANCELED, null);
        finish();
    }

    private class MyAsyncTask extends AsyncTask<Integer, String, Boolean> {
        private Context context;

        public MyAsyncTask(Context context) {
            this.context = context;
        }

        protected Boolean doInBackground(Integer... params) {
            try {
                GMailSender sender = new GMailSender(
                        "urlIsHere", "EmbraceChaos");
                sender.sendMail(subj, body, from, toList);
            } catch (Exception e) {
                System.out.println("EXCEPTION: " + e);
                setContentView(R.layout.send_failed);
            }
            return true;
        }

        protected void onPostExecute(Boolean result) {
            Toast.makeText(context,
                    "Latest media was uploaded to Virtual Command Center.",
                    Toast.LENGTH_LONG).show();
        }
    }
}
显示

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.cameratest"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="9"
        android:targetSdkVersion="15" />

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.RECORD_VIDEO" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".Main"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="sate2012.avatar.android.UploadMedia"
            android:label="@string/app_name"
            android:screenOrientation="landscape" >
        </activity>
        <activity
            android:name="sate2012.avatar.android.MailSenderActivity"
            android:label="Upload Data Point" >
            <intent-filter>
                <action android:name="android.intent.action.MAILSENDERACTIVITY" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name="sate2012.avatar.android.GMailSender"
            android:label="@string/title_mail_sender_activity"
            android:screenOrientation="landscape" >
            <intent-filter>
                <action android:name="sate2012.avatar.android.GMAILSENDER" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name="sate2012.avatar.android.UploadData"
            android:label="UploadData" >
            <intent-filter>
                <action android:name="sate2012.avatar.android.UPLOADDATA" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name=".UploadMedia"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.UPLOAD_MEDIA" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name=".Photographer"
            android:label="photoclass" >
            <intent-filter>
                <action android:name="android.intent.action.PHOTOGRAPHER" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".UploadFTP"
            android:label="photoclass" >
            <intent-filter>
                <action android:name="android.intent.action.UPLOAD_FTP" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".MailSenderActivity"
            android:label="photoclass" >
            <intent-filter>
                <action android:name="android.intent.action.MAILSENDERACTIVITY" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

我已经解决了问题,发现源代码缺少对xml文件的不正确引用。我修复了它,错误不再发生

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.cameratest"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="9"
        android:targetSdkVersion="15" />

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.RECORD_VIDEO" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".Main"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="sate2012.avatar.android.UploadMedia"
            android:label="@string/app_name"
            android:screenOrientation="landscape" >
        </activity>
        <activity
            android:name="sate2012.avatar.android.MailSenderActivity"
            android:label="Upload Data Point" >
            <intent-filter>
                <action android:name="android.intent.action.MAILSENDERACTIVITY" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name="sate2012.avatar.android.GMailSender"
            android:label="@string/title_mail_sender_activity"
            android:screenOrientation="landscape" >
            <intent-filter>
                <action android:name="sate2012.avatar.android.GMAILSENDER" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name="sate2012.avatar.android.UploadData"
            android:label="UploadData" >
            <intent-filter>
                <action android:name="sate2012.avatar.android.UPLOADDATA" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name=".UploadMedia"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.UPLOAD_MEDIA" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name=".Photographer"
            android:label="photoclass" >
            <intent-filter>
                <action android:name="android.intent.action.PHOTOGRAPHER" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".UploadFTP"
            android:label="photoclass" >
            <intent-filter>
                <action android:name="android.intent.action.UPLOAD_FTP" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".MailSenderActivity"
            android:label="photoclass" >
            <intent-filter>
                <action android:name="android.intent.action.MAILSENDERACTIVITY" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>