• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Activity must be exported....

HH12321

Lurker
Jul 17, 2017
4
0
I've developed a relatively basic app (or at least tried to), but have not managed to get it to run. I had one set of error messages, left it a while, needed to upgrade the Android App Development Studio, and now have a new error!

If I try to run it, I get the following "The Activity must be exported or contain an intent-filter". Could anyone please advise what this means? Do I need to set up some kind of backup file, or save something in the right location?

Happy to provide more information to anyone who can help me.
 
Need to see:-

1. Manifest file
2. Code for Activity
3. The complete error message, from the log file

Please put all XML and code in between [code][/code] tags

Thanks!

Thanks so much for such a speedy response! I've just tried hunting around for the manifest file (it's been a little while) and what I thought it was apparently has an illegal file type to upload here. Could you possibly enlighten me? What's the likely suffix? And where should it be in the file structure?

Please let me know if the following is in the wrong format or if I've done something wrong. Maybe if the manifest file has disappeared that could be the whole issue!

The error message is:
17:02 Error running ActivityEnergyUsage: The activity must be exported or contain an intent-filter

The code is as follows:

Code:
ackage com.example.hannahhoward.carboncardiobalancing;

import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.appindexing.Thing;
import com.google.android.gms.common.api.GoogleApiClient;

public class ActivityEnergyUsage extends AppCompatActivity {

    /**
     * ATTENTION: This was auto-generated to implement the App Indexing API.
     * See https://g.co/AppIndexing/AndroidStudio for more information.
     */
    private GoogleApiClient client;

    public void click3(View v){}
    Intent goToMainActivity=onNewIntent();
        goToMainActivity.setclass(this,MainActivity.class)
    ActivityEnergyUsage(goToMainActivity){
        finish();}

        protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_energy_usage);
        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
    }

    Spinner spinner_energyactivity = (Spinner) findViewById(spinner_energyactivity);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.energyusage_array, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    Spinner spinner_duration = (Spinner) findViewById(spinner_duration);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.duration_array, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    /**
     * ATTENTION: This was auto-generated to implement the App Indexing API.
     * See https://g.co/AppIndexing/AndroidStudio for more information.
     */
    public Action getIndexApiAction() {
        Thing object = new Thing.Builder()
                .setName("ActivityEnergyUsage Page") // TODO: Define a title for the content shown.
                // TODO: Make sure this auto-generated URL is correct.
                .setUrl(Uri.parse("http://[ENTER-YOUR-URL-HERE]"))
                .build();
        return new Action.Builder(Action.TYPE_VIEW)
                .setObject(object)
                .setActionStatus(Action.STATUS_TYPE_COMPLETED)
                .build();
    }



    }

    [USER=1021285]@override[/USER]
    public void onStart() {
        super.onStart();

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client.connect();
        AppIndex.AppIndexApi.start(client, getIndexApiAction());
    }

    [USER=1021285]@override[/USER]
    public void onStop() {
        super.onStop();

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        AppIndex.AppIndexApi.end(client, getIndexApiAction());
        client.disconnect();
    }
 
Last edited by a moderator:
Upvote 0
Thanks - I have at least found the manifest file, so that is there, but it won't let me upload it here as it says that I can't upload a file with this extension.

I've copied and pasted the contents of the file below in case that's of use. Do you think that the issue could be that I had to copy my entire folder across and the folder it is now in is called: D:\HannahHoward\CarbonCardioBalancing_Test\app\src\main? Do I need to manually modify the manifest so that it references "_Test" within the <manifest package part?

Code:
<?xml version="1.0" encoding="UTF-8"?>

-<manifest package="com.example.hannahhoward.carboncardiobalancing" xmlns:android="http://schemas.android.com/apk/res/android">


-<application android:theme="[USER=19691]@Style[/USER]/AppTheme" android:supportsRtl="true" android:label="[USER=696546]@String[/USER]/app_name" android:icon="[USER=22138]@Mipmap[/USER]/ic_launcher" android:allowBackup="true">


-<activity android:name=".MainActivity">


-<intent-filter>

<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>

</intent-filter>

</activity>

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

<!-- ATTENTION: This was auto-generated to add Google Play services to your project for App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information. -->


<meta-data android:name="com.google.android.gms.version" android:value="[USER=1111536]@integer[/USER]/google_play_services_version"/>

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

</application>

</manifest>
 
Last edited by a moderator:
Upvote 0
I'd start by removing the '-' characters at the beginning of some lines in your manifest.

Another question I have for you is - what's the full package name of your MainActivity class? I'd use that in the manifest, instead of just ".MainActivity"
Thanks very much for your response LV426. I'm sorry to be so ignorant, however, the manifest was created directly when I built the xml files in the Android Studio. If I look in the text tab of the xml there then I don't have any of the '-' so I don't know how I can remove them from the manifest. Any suggestions?

Likewise, the reference to the activity has been set up directly within the studio. Does that make sense?

Thanks
 
Upvote 0
You said that you'd copied your code from one place to another. That may well have screwed things up.
I would re-create the project again, within Android Studio. The new project wizard sets all this stuff up for you, and leaves you with a blank project skeleton, containing just the basic configuration files, such as the Manifest. Once the project structure is set up, you can proceed to populate it with your Activities and other code.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones