简体   繁体   中英

Android using Intents

I'am having trouble to call an intent out off my app so say I have the main class [A] I'm having trouble to call the downloader class [B] via Intent

All classes have a own layout and other functions

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>

Please help me and thank you

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)

Use your Intent like this.

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

hope this helps...

Use this for Intent:

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

If your class is implementing onClickListener (say), then use the following to create intent

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

If you are providing the clicking event listener as an anonymous inner class, then use the follow

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM