我正在使用admob来展示Android广告.测试广告工作正常,但不显示真实广告.此外,我对实际的插页式广告没有任何问题,因为它们运行良好.只是真正的横幅广告没有出现.我的java代码是
private InterstitialAd interstitial;
interstitial = new InterstitialAd(MainActivity.this);
interstitial.setAdUnitId("ca-app-pub-********");
AdView adView = (AdView) this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
// Add a test device to show Test Ads
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("4CCC00EF4EA205A6FE82E1AEB26B0839")
.build();
// Load ads into Banner Ads
adView.loadAd(adRequest);
// Load ads into Interstitial Ads
//interstitial.loadAd(adRequest);
Run Code Online (Sandbox Code Playgroud)
布局文件是
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-********" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我正在尝试从其他服务启动服务.但想知道出了什么问题.代码就像
class Service1 extends GCMBaseIntentService {
@Override
protected void onMessage(Context arg0, Intent intent) {
Toast.makeText(getApplicationContext(), "Hello", Toast.LENGTH_LONG).show();
Intent service = new Intent(getApplicationContext(), Service2.class);
startService(service);
}
}
Run Code Online (Sandbox Code Playgroud)
而Service2则是
class Service2 extends Service {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "Service Started", Toast.LENGTH_LONG).show();
}
}
Run Code Online (Sandbox Code Playgroud)
我在Service1中获得了Toast"Hello",但没有从Service2获得Toast"Service Started"
我正在使用actionbarsherlock开发一个应用程序,ABS项目目前正在使用android-support-v4库(版本18).现在我想扩展我的项目以支持Android 6.0并使用一些方法
ContextCompat.checkSelfPermission(thisActivity, Manifest.permission.WRITE_CALENDAR)
Run Code Online (Sandbox Code Playgroud)
要么
ActivityCompat.shouldShowRequestPermissionRationale(thisActivity, Manifest.permission.READ_CONTACTS)
Run Code Online (Sandbox Code Playgroud)
我需要支持库版本23.但是ABS项目与这个最新的库不兼容并且给出了mAdded无法解决的错误或者不是 Watson.java中的字段
此外,请不要建议我使用AppCompatActivity而不是ABS,因为我尝试了它,但因为我的项目非常大而陷入其他混乱的网络中.