zoukankan      html  css  js  c++  java
  • startActivityForResult报错

    startActivityForResult报错!

    startActivityForResult(new Intent(MainActivity.this, OtherActivity.class), 0);

    骗子!从教程、网上滴字不漏抄来的例子,运行居然报错!

    后来抄翻互联网,才知道要在AndroidManifest.xml 加上这么一句:

    <activity android:name=".OtherActivity" />

    其中,OtherActivity是新加入的Activity。启动Activity是MainActivity。完整的AndroidManifest.xml是:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.cq.activity2"
        android:versionCode="1"
        android:versionName="1.0" >
    
        <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="16" />
    
        <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name=".MainActivity"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <activity android:name=".OtherActivity" /> 
        </application>
    
    </manifest>

    但教程和网上的例子,只一味地罗列代码,而这个配置文件却提都不提,真他妈的。



  • 相关阅读:
    stat函数讲解
    ptrace 人人小站
    调试器工作原理——基础篇
    open和fopen的区别:
    memset ,memcpy 和strcpy 的根本区别?
    log4j日志配置详解
    jvm调优的参数设置
    mysql的密码设置
    java基础类、接口、成员属性的修饰符
    java基础之类(包含内部类)与接口的特点
  • 原文地址:https://www.cnblogs.com/leftfist/p/4258033.html
Copyright © 2011-2022 走看看