简体   繁体   中英

Android app installs but doesnt show up

I've been looking around and I can't seem to find an answer for this. My android app compiles correctly, no errors or anything, and it installs correctly, but it won't show up in the app drawer, and the "Open" button is greyed out. Here is my Main Activity

package com.dogger20011.app;

import android.support.v7.app.ActionBarActivity;
import android.support.v4.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.os.Build;

 public class MainActivity extends ActionBarActivity {

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

    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
                .add(R.id.container, new                         

PlaceholderFragment()).commit();
    }
  }

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.Downloads) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}

/**
 * A placeholder fragment containing a simple view.
 */
public static class PlaceholderFragment extends Fragment {

    public PlaceholderFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_main, container,
                false);
        return rootView;
    }
}
 }

Got any ideas? Thanks!

You have your main activity placed after the intent filter which makes your mainActivity as the launcher. Please correct the XML like below (Basically, MainActivitiy related stuff) And also Removed the maxSDKVersion tag from teh Uses-permission

Finally it should be like this:

 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dogger20011.app"
android:versionCode="1"
android:versionName="1.0.5" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name">

<activity
    android:name="com.dogger20011.app.MainActivity"
    android:label="@string/app_name"/>

<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<activity
        android:label="@string/app_name"
        android:name=".AppActivity"/>
<activity
        android:label="@string/app_name"
        android:name=".AppActivity_modD"/>
<activity
        android:label="@string/app_name"
        android:name=".App2Activity"/>
<activity
        android:label="@string/app_name"
        android:name=".AppActivity_ModD2"/>

</application>
</manifest>

Your MainActivity shouldn't make a difference, it's all about the manifest. Your main activity block should look like this:

<activity
    android:name="com.dogger20011.app.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>

Note that the <intent-filter> block needs to be nested within the <activity> block.

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