我构建了一个简单的FlashLight应用程序,因为我是Android Dev的新手。所以我想将Admob整合到应用程序中。在这样做之后,只需几行代码,当我生成APK并安装在Android手机上时,我无法在启动器中找到图标,而且我不仅可以在安装后看到“完成”和“打开”选项。所以我需要你的帮助。 这是androidManifest.xml中的代码
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<!-- Include required permissions for Google Mobile Ads to run. -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- This meta data is used to use Google Play Services -->>
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<!-- Include the AdActivity configChanges and theme. -->
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
</application>
这是activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_height="fill_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
android:weightSum="1"
android:background="#ff18ba75">
<ImageButton
android:id="@+id/flashSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:src="@drawable/toggle_switch"
android:minWidth="120dp"
android:minHeight="120dp"
android:scaleType="fitXY"
android:background="#ff18ba75"
android:contentDescription="@string/Description" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/Developer"
android:textStyle="italic"
android:id="@+id/textView"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<!-- I Tried removing this Adview lines of code and that fix the error, So I guess the problem is somewhere else.
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit"
/>
</RelativeLayout>
答案 0 :(得分:0)
您的应用的主要活动必须在清单中声明,其中包含LAUNCHER
操作和<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>
类别。例如:
<application
<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="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
</application
如果未针对您的某项活动宣布MAIN操作或LAUNCHER类别,那么您的应用图标将不会显示在主屏幕的应用列表中。
如果您要添加AdView,则需要添加另一个活动,如下所示:
char *ext[3] = {"jpg", "gif", "png"};
您可能不小心将现有活动替换为AdActivity。