Android使用Intents

时间:2012-02-14 13:02:07

标签: java android android-intent android-manifest

我很难从我的应用中调出一个意图 所以说我有主要班级[A] 我无法调用下载器类[B] 通过意图

所有课程都有自己的布局和其他功能

Main.java:

[...]
        Intent i = new Intent(".downloader");
        startActivity(i);
        // toaster("Please wait...");
[...]

downloader.java:

public class dowloader extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.downloader);



    }
}

Androidmanifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="folder.hide.alexander.fuchs"
    android:versionCode="3"
    android:versionName="1.3.1" >

      <uses-sdk android:minSdkVersion="8" />

<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>


<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".App"
            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=".downloader" /> 
    </application>

</manifest>

请帮帮我 谢谢你

Logcat:

02-14 14:07:42.539: E/AndroidRuntime(32755): FATAL EXCEPTION: main
02-14 14:07:42.539: E/AndroidRuntime(32755): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=.downloader }
02-14 14:07:42.539: E/AndroidRuntime(32755):    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409)
02-14 14:07:42.539: E/AndroidRuntime(32755):    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
02-14 14:07:42.539: E/AndroidRuntime(32755):    at android.app.Activity.startActivityForResult(Activity.java:2833)
02-14 14:07:42.539: E/AndroidRuntime(32755):    at android.app.Activity.startActivity(Activity.java:2959)
02-14 14:07:42.539: E/AndroidRuntime(32755):    at folder.hide.alexander.fuchs.App.onClick(App.java:333)
02-14 14:07:42.539: E/AndroidRuntime(32755):    at android.view.View.performClick(View.java:2538)
02-14 14:07:42.539: E/AndroidRuntime(32755):    at android.view.View$PerformClick.run(View.java:9152)
02-14 14:07:42.539: E/AndroidRuntime(32755):    at android.os.Handler.handleCallback(Handler.java:587)
02-14 14:07:42.539: E/AndroidRuntime(32755):    at android.os.Handler.dispatchMessage(Handler.java:92)
02-14 14:07:42.539: E/AndroidRuntime(32755):    at android.os.Looper.loop(Looper.java:130)
02-14 14:07:42.539: E/AndroidRuntime(32755):    at android.app.ActivityThread.main(ActivityThread.java:3691)
02-14 14:07:42.539: E/AndroidRuntime(32755):    at java.lang.reflect.Method.invokeNative(Native Method)
02-14 14:07:42.539: E/AndroidRuntime(32755):    at java.lang.reflect.Method.invoke(Method.java:507)
02-14 14:07:42.539: E/AndroidRuntime(32755):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
02-14 14:07:42.539: E/AndroidRuntime(32755):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
02-14 14:07:42.539: E/AndroidRuntime(32755):    at dalvik.system.NativeStart.main(Native Method)

4 个答案:

答案 0 :(得分:3)

像这样使用你的意图。

Intent intent = new Intent(yourCurrentClass.this,
                    nextClass.class);
            startActivity(intent);

希望这会有所帮助...

答案 1 :(得分:0)

将此用于意图:

Intent in=new Intent(Hello.this,welcome.class);
startActivity(in);

答案 2 :(得分:0)

如果您的类正在实现onClickListener(例如),那么使用以下命令创建意图

Intent intent = new Intent(this, DestinationClassName.class);
startActivity(intent);

如果您将click事件侦听器作为匿名内部类提供,请使用以下

Intent intent = new Intent(CurrentClassName.this, DestinationClassName.class);
startActivity(intent);

答案 3 :(得分:0)

Intent intent = new Intent(CurrentClass.this, downloader.class);
startActivity(intent);