我正在尝试将AdMob广告显示在我的Android应用程序中,并且无法这样做.我已经联系了他们的支持,并且在将近一周内没有收到任何回复,所以我想我现在会在这里寻求帮助.
首先是一些代码:
AndroidManifest.xml
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1" package="com.foo.application">
<application>
<meta-data
android:value="admob-publisher-id-here"
android:name="ADMOB_PUBLISHER_ID" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Run Code Online (Sandbox Code Playgroud)
是的,admob-publisher-id-here是我在实际清单文件中的真正发布者ID.
main_layout.xml
<LinearLayout
android:id="@+id/adhost"
android:layout_width="fill_parent"
android:padding="5dip" android:layout_height="wrap_content"
android:minHeight="20dip"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.foo.application">
<com.admob.android.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:backgroundColor="#000000"
app:primaryTextColor="#FFFFFF"
app:secondaryTextColor="#CCCCCC"
app:keywords="android at&t t-mobile iphone blah"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
attr.xml
<resources>
<declare-styleable name="com.admob.android.ads.AdView">
<attr name="backgroundColor" format="color" />
<attr name="primaryTextColor" format="color" />
<attr name="secondaryTextColor" format="color" />
<attr name="keywords" format="string" />
<attr name="refreshInterval" format="integer" />
</declare-styleable>
</resources>
Run Code Online (Sandbox Code Playgroud)
MainActivity.java
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import com.admob.android.ads.AdManager;
import com.admob.android.ads.AdView;
import …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个简单的异常处理程序,它将帮助我调试应用程序.现在,当我遇到异常时,我被迫连接Eclipse调试器只是为了查看异常细节.
为了避免这种情况,我使用了setUncaughtExceptionHandler来处理任何未处理的异常并在异常上显示Toast.不幸的是,这不起作用.
public class TicTacToe extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Thread.currentThread().setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable ex) {
Toast.makeText(TicTacToe.this, "TOAST", Toast.LENGTH_LONG).show();
}
});
setContentView(R.layout.main);
Button continueButton = (Button) findViewById(R.id.cell01);
continueButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int i = 5;
i = 5 / 0;
Toast.makeText(TicTacToe.this, "BUTTON", Toast.LENGTH_LONG).show();
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
基本上我用一个按钮制作了一个表单,按下它,它将抛出一个零度异常.但是,按下按钮不会导致显示全局Toast处理程序.相反,按钮保持橙色(按下),没有任何反应.
不用说,如果我评论出i = 5/0; 我看到吐司说按了一个按钮.
两个问题:1)为什么在 …
我有一个写入的安装程序HKLM\Software\DroidExplorer\InstallPath.在任何x86机器上它都可以正常写入预期的位置,而在Windows XP x64和Windows 7 x64上它也会写入预期的位置,实际上是这样HKLM\Software\Wow6432Node\DroidExplorer\InstallPath.
稍后在安装过程中,我的引导程序(也是x86)会尝试读取该值.在所有x86 Windows机器上它都是成功的,在Windows XP x64和Windows 7 x64上,但Windows Vista x64无法找到密钥.如果我查看注册表,它实际上并没有将它写入Windows Vista上的Wow6432Node; 它把它写到Software\DroidExplorer\InstallPath.
如果我没有强行告诉安装程序写入Wow6432Node,它会将值写入Software\DroidExplorer\InstallPath,但由于注册表反射,引导程序仍然会尝试查找Wow6432Node .这适用于所有x64系统.
为什么Windows Vista x64是我遇到此问题的唯一一个?有没有解决的办法?
我只是想添加一个仍然打开的编辑.以下建议均未解决此问题.
如何使用自己的图像创建自定义Android虚拟设备?我一直在尝试在sdk\platforms\android\images中自己更改默认*.img-s,但它没有帮助 - 模拟器没有启动或冻结.
提前致谢!
几天前我用2.2(Froyo)升级了我的Nexus One.今天早上当我去使用它时,我看到一个Dialog坐在家庭/启动器屏幕的顶部,通知我有更新可用,我现在或以后可以选择升级.
我的问题是,这个用于在主屏幕上显示Dialog(可能是AlertDialog)的API机制是什么?编写了一个Android应用程序后,我的理解是Dialogs只能显示在一个Activity上,并且一个服务无法显示一个Dialog(只有一个Toast).
谷歌是否可能将活动看起来像对话框?是否有新的API方法可用于显示Dialog而无需Activity?