本文整理匯總了Java中com.google.android.gms.ads.AdRequest.Builder類的典型用法代碼示例。如果您正苦於以下問題:Java Builder類的具體用法?Java Builder怎麽用?Java Builder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Builder類屬於com.google.android.gms.ads.AdRequest包,在下文中一共展示了Builder類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createLayoutWithAd
import com.google.android.gms.ads.AdRequest.Builder; //導入依賴的package包/類
public static LinearLayout createLayoutWithAd(Activity activity) {
LinearLayout layout = new LinearLayout(activity);
layout.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
lp.gravity = Gravity.CENTER_HORIZONTAL;
AdView goodAdv = new AdView(activity); //, com.google.ads.AdSize.BANNER, GOOGLE_AD_ID
if (LiveWallpaperSettings.DEBUG) {
goodAdv.setAdUnitId("");
} else {
goodAdv.setAdUnitId("ca-app-pub-7879767097814866/4363554030");
}
goodAdv.setAdSize(AdSize.BANNER);
layout.addView(goodAdv);
AdRequest.Builder builder = new Builder();
goodAdv.loadAd(builder.build());
return layout;
}
示例2: loadAd
import com.google.android.gms.ads.AdRequest.Builder; //導入依賴的package包/類
public static void loadAd(final View view){
final Builder builder = new AdRequest.Builder();
builder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR); // Emulator
// Add test devices
final String[] testDevices = view.getContext().getString(R.string.testDevices).split(",");
for (String testDevice:testDevices){
builder.addTestDevice(testDevice);
}
final AdView adView = (AdView) view.findViewById(R.id.adView);
adView.loadAd(builder.build());
}
示例3: sendNotification
import com.google.android.gms.ads.AdRequest.Builder; //導入依賴的package包/類
public static void sendNotification(final Context context,final String postfix,final String message){
final Notification.Builder mBuilder =
new Notification.Builder(context)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(context.getText(R.string.app_name)+" "+postfix)
.setContentText(message);
// Creates an explicit intent for an Activity in your app
final Intent resultIntent = new Intent(context, MainActivity.class);
// The stack builder object will contain an artificial back stack for the
// started Activity.
// This ensures that navigating backward from the Activity leads out of
// your application to the Home screen.
final TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
// Adds the back stack for the Intent (but not the Intent itself)
stackBuilder.addParentStack(MainActivity.class);
// Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);
final NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (mNotificationManager!=null) {
// mId allows you to update the notification later on.
int mId = 0;
mNotificationManager.notify(mId, mBuilder.build());
Analytics.getInstance().logEvent(TAG, "sendNotification", "message");
}
}
示例4: showPopup
import com.google.android.gms.ads.AdRequest.Builder; //導入依賴的package包/類
public static void showPopup(final int id,final Activity activity,final ImagePopupListener listener,final String title,final String message,final int imageResource,final Long automaticDismissDelay){
final String tag="showPopup - ";
activity.runOnUiThread(new Runnable() {
public void run() {
final AlertDialog.Builder ad = new AlertDialog.Builder(activity);
ad.setTitle(title);
ad.setMessage(Html.fromHtml(message));
ad.setIcon(imageResource);
ad.setNeutralButton("OK", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface arg0, int arg1) {
if (listener!=null){
listener.onImagePopupDispose(id);
}
}
});
final AlertDialog alert = ad.create();
alert.show();
if (automaticDismissDelay != null) {
final Handler handler = new Handler();
final Runnable runnable = new Runnable() {
public void run() {
if (alert.isShowing()) {
try {
alert.dismiss();
} catch (IllegalArgumentException e) {
// FIXME: Ugly fix (View not attached to window manager)
Log.e(TAG,tag+"Auto dismiss", e);
}
}
}
};
handler.postDelayed(runnable, automaticDismissDelay);
}
}
});
}