java.lang.NullPointerException:尝试调用虚拟内存

java.lang.NullPointerException:尝试调用虚拟内存,java,android,android-studio,Java,Android,Android Studio,当我尝试运行我的应用程序时,我收到了这个错误。我认为我的菜单按钮导致了这个错误,但我真的不知道如何解决这个问题 <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:them

当我尝试运行我的应用程序时,我收到了这个错误。我认为我的菜单按钮导致了这个错误,但我真的不知道如何解决这个问题

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".AboutActivity"
            android:screenOrientation="portrait"/>
        <activity android:name=".SecondActivity"/>
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
main活动

package com.example.vitoriano_vaz.eastbayvapes;

import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

import java.util.List;

/*
This app is for a local Vape Shop
 it's purpose is to increase customer flow, and provide a menu for Android users

 the array is going to be called = da_menu
 */
public class MainActivity extends AppCompatActivity {
    private static Intent java;

    //used this to get rid of red line under intent on line 38 if it causes more problems remove and resolve issue
    private Intent intent;

    /*
    called when the user clicks the send Button
     */

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        /*
        attempting to send user to each individual app with the URI Intent method
         */
        PackageManager packageManager = getPackageManager();
        List activites = packageManager.queryIntentActivities(intent,
                PackageManager.MATCH_DEFAULT_ONLY);
        boolean isIntentSafe = activites.size() > 0;

        Uri number = Uri.parse("tel:9259619029");
        Intent callIntent = new Intent(Intent.ACTION_DIAL, number);

        Uri webpage = Uri.parse("http://www.facebook.com/eastbayvapes");
        Intent webIntent = new Intent(Intent.ACTION_VIEW, webpage);

        /*this is to send the user to facebook application

        try {

            context.getPackageManager().getPackageInfo("com.facebook.katana", 0);
            return new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/eastbay"));

        } catch (Exception e) {

            return new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/eastbay"));

        }
        */


        // intent to send user to instagram

        Uri uri = Uri.parse("http://instagram.com/_u/eastbayvapes");
        Intent likeIng = new Intent(Intent.ACTION_VIEW, uri);

        likeIng.setPackage("com.instagram.android");

        try {
            startActivity(likeIng);
        } catch (ActivityNotFoundException e) {
            startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://instagram.com/eastbayvapes")));
        }

        //Intent to send user to email app

        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("plain/text");
        intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"eastbayvapes@gmail.com"});
        intent.putExtra(Intent.EXTRA_SUBJECT, "subject");
        intent.putExtra(Intent.EXTRA_TEXT, "");
        startActivity(Intent.createChooser(intent, ""));

        /*Intent to send user to google maps

        String uri = "https://maps.google.co.in/maps?q=" + 1549 N Vasco Rd, Livermore, Ca 94551;
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
        context.startActivity(intent);
        */



        /*
        sends user to about us xml via AboutActivity.class
         */
        Button button = (Button) findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, AboutActivity.class);
                startActivity(intent);
            }
        });




    }


}
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".AboutActivity"
            android:screenOrientation="portrait"/>
        <activity android:name=".SecondActivity"/>
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollIndicators="right">

    <ListView
        android:id="@+id/listViewMain"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true" />

</RelativeLayout>
第二活动 在这里,当我声明菜单按钮时,我相信我得到了错误的原因,但不知道我做错了什么

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".AboutActivity"
            android:screenOrientation="portrait"/>
        <activity android:name=".SecondActivity"/>
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
package com.example.vitoriano_vaz.eastbayvapes;
导入android.os.Bundle;
导入android.support.v7.app.AppActivity;
导入android.view.view;
导入android.widget.ArrayAdapter;
导入android.widget.Button;
导入android.widget.ListView;
/**
*维托里亚诺·瓦兹于2016年5月11日创作。
*/
公共类SecondActivity扩展了AppCompatActivity{
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.menuscreen);
/*
这是将用户发送到menuscreen.xml的按钮调用
*/
按钮mbutton=(按钮)findViewById(R.id.menubutton);
mbutton.setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图v){
populateListView();
}
});
populateListView();
}
私有void populateListView(){
//创建项目列表
字符串[]juiceMenu={
“#1蓝莓炸弹\n这款蓝莓甜点会让你的味蕾不断乞求更多”,
“#2里奇·里奇\n向里奇致敬!这是他一整天的工作。草莓奶油加上一束美味”,
“#3 CHIQUITA\n口味后配面包的烤香蕉”,
“#4午后甜点\n有3点钟的感觉吗?试试午后甜点。猕猴桃草莓甜点”,
“#5只罂粟水獭\n将一只水獭放在你的水箱中,然后用吸管吸干”,
“#6桑格里亚万岁\n水果,加一点水果,加一茶匙混合白葡萄酒的水果,最后加水果”,
“#7 OKOLE MALUNA\n苹果水果混合物。自下而上!”,
“#8卡门·米兰达\n脆奶油冻”,
“#9 POMALADE \n这是Bombalade!你妈妈会喜欢的”,
“#10 IZUAL\n冰凉水果之风”,
“#11黄油斯托奇\n混沌教授肯定会因为这一次被禁足!”,
“#12头蓝牛\n抓住公牛的角”,
“#13只葡萄猿\n每天抓斗可以让医生远离你”,
“#14 BRUCE JUICE\n完美混合的老式。这是给你的BRUCE”,
“#15 DOC HOLIDAY\nN.E.T.烟草口味有限版”,
“#16个桃子皮匠,比你妈妈以前做的好”,
“17草裙舞\n草莓椰子?草裙舞里有什么?”,
“#18纽约\nPeppermit paddy蘸巧克力……真是太棒了”,
“#19阿尔·戈尔\n现在就吃超级杜珀麦片!”,
“#20勒克斯护身符\n艺术、星星、马蹄铁、三叶草和蓝色月亮、金罐%彩虹和红色气球”,
“#21水手杰克\n去球赛时没有饼干杰克”,
“#22带他去希腊餐厅\n……酸奶、桃子、美味”,
“#23键WE LIE CHI\n水果爱好者会喜欢这款荔枝皮”,
“#24春游\n在你的舌头上涂上一层蜜露和奶油”,
“#25树胶\n西瓜酸树胶”,
“#26柴\n牛奶和柴茶”,
“#27贝恩先生\n用奶油来开始新的一天”,
“#28 50种橙色\n一种令人愉悦的橙色和奶油的混合物”,
“#29块蓝色华夫饼干\n晚餐时用这种蓝莓华夫饼干吃脆”,
“#30谜团\nEnigma芒果覆盆子的谜团带着一丝神秘,你能解开谜团吗?”,
“#31冷冻先生\n放下水箱,离开铁杆薄荷爱好者!这种果汁对大多数人来说太辣了”,
“#32杯咖啡\n醒来时最好的部分是在你的鞋面里喝咖啡”,
“#33 BON JOVI\nVanilla Bourbon”,
};
//构建适配器
ArrayAdapter适配器=新的ArrayAdapter(
这是活动的,//上下文
R.layout.da_菜单,//要创建的布局
juiceMenu);//要显示的项目
//配置列表视图
ListView列表=(ListView)findViewById(R.id.listViewMain);
list.setAdapter(适配器);
}
}
AndroidManifest

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".AboutActivity"
            android:screenOrientation="portrait"/>
        <activity android:name=".SecondActivity"/>
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

主要活动

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".AboutActivity"
            android:screenOrientation="portrait"/>
        <activity android:name=".SecondActivity"/>
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:src="@drawable/ebvbottle"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.vitoriano_vaz.eastbayvapes.MainActivity">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="East Bay Vapes"
        android:textAllCaps="true"
        android:textColor="#FEFEFF"
        android:textSize="28sp"
        android:textStyle="bold"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="onClick"
        android:text="About Us"
        android:layout_below="@+id/textView"
        android:layout_alignParentStart="true" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Menu"
        android:id="@+id/menubutton"
        android:layout_alignTop="@+id/button"
        android:layout_alignParentEnd="true"
        android:onClick="menubutton" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="We are dedicated to helping people get off tabacco! We carry everything from beginner setups, to advanced personalized vaporizers. We pride ourselves in our premuim juices made in shop!"
        android:id="@+id/textView2"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:textSize="22dp"
        android:typeface="serif" />

</RelativeLayout>

菜单屏幕 这里是我要发送填充数组的位置

package com.example.vitoriano_vaz.eastbayvapes;

import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

import java.util.List;

/*
This app is for a local Vape Shop
 it's purpose is to increase customer flow, and provide a menu for Android users

 the array is going to be called = da_menu
 */
public class MainActivity extends AppCompatActivity {
    private static Intent java;

    //used this to get rid of red line under intent on line 38 if it causes more problems remove and resolve issue
    private Intent intent;

    /*
    called when the user clicks the send Button
     */

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        /*
        attempting to send user to each individual app with the URI Intent method
         */
        PackageManager packageManager = getPackageManager();
        List activites = packageManager.queryIntentActivities(intent,
                PackageManager.MATCH_DEFAULT_ONLY);
        boolean isIntentSafe = activites.size() > 0;

        Uri number = Uri.parse("tel:9259619029");
        Intent callIntent = new Intent(Intent.ACTION_DIAL, number);

        Uri webpage = Uri.parse("http://www.facebook.com/eastbayvapes");
        Intent webIntent = new Intent(Intent.ACTION_VIEW, webpage);

        /*this is to send the user to facebook application

        try {

            context.getPackageManager().getPackageInfo("com.facebook.katana", 0);
            return new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/eastbay"));

        } catch (Exception e) {

            return new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/eastbay"));

        }
        */


        // intent to send user to instagram

        Uri uri = Uri.parse("http://instagram.com/_u/eastbayvapes");
        Intent likeIng = new Intent(Intent.ACTION_VIEW, uri);

        likeIng.setPackage("com.instagram.android");

        try {
            startActivity(likeIng);
        } catch (ActivityNotFoundException e) {
            startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://instagram.com/eastbayvapes")));
        }

        //Intent to send user to email app

        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("plain/text");
        intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"eastbayvapes@gmail.com"});
        intent.putExtra(Intent.EXTRA_SUBJECT, "subject");
        intent.putExtra(Intent.EXTRA_TEXT, "");
        startActivity(Intent.createChooser(intent, ""));

        /*Intent to send user to google maps

        String uri = "https://maps.google.co.in/maps?q=" + 1549 N Vasco Rd, Livermore, Ca 94551;
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
        context.startActivity(intent);
        */



        /*
        sends user to about us xml via AboutActivity.class
         */
        Button button = (Button) findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, AboutActivity.class);
                startActivity(intent);
            }
        });




    }


}
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".AboutActivity"
            android:screenOrientation="portrait"/>
        <activity android:name=".SecondActivity"/>
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollIndicators="right">

    <ListView
        android:id="@+id/listViewMain"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true" />

</RelativeLayout>

这是我的错误

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".AboutActivity"
            android:screenOrientation="portrait"/>
        <activity android:name=".SecondActivity"/>
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
05-18 16:00:44.619 11983-11983/com.example.vitoriano_vaz.eastbayvapes E/AndroidRuntime:FATAL EXCEPTION:main
流程:com.example.vitoriano_vaz.eastbayvapes,PID:11983
java.lang.RuntimeException:无法启动activity ComponentInfo{com.example.vitoriano_vaz.eastbayvapes/com.example.vitoriano_vaz.eastbayvapes.MainActivity}:java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法“java.lang.String.android.content.Intent.resolveTypeIfNeeded(android.content.ContentResolver)”
在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2622)上