示例#1
0
  public static void addAd(Activity a) {

    AppConnect.getInstance(a).initPopAd(a);
    // 设置插屏广告无数据时的回调监听(该方法必须在showPopAd之前调用)
    AppConnect.getInstance(a)
        .setPopAdNoDataListener(
            new AppListener() {

              @Override
              public void onPopNoData() {
                Log.i("debug", "插屏广告暂无可用数据");
              }
            });
    // 显示插屏广告
    AppConnect.getInstance(a).showPopAd(a);
  }
示例#2
0
 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   this.requestWindowFeature(Window.FEATURE_NO_TITLE);
   getWindow()
       .setFlags(
           WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
   setContentView(R.layout.first);
   AppConnect.getInstance(this);
   Thread splashThread =
       new Thread() {
         @Override
         public void run() {
           try {
             int waited = 0;
             while (waited < 5000) {
               sleep(100);
               waited += 100;
             }
           } catch (InterruptedException e) {
             // do nothing
           } finally {
             finish();
             Intent i = new Intent();
             i.setClassName("com.lxm.txtapp", "com.lxm.txtapp.MainActivity");
             startActivity(i);
           }
         }
       };
   splashThread.start();
 }
示例#3
0
 @Override
 protected void onResume() {
   // 从服务器端获取当前用户的虚拟货币.
   // 返回结果在回调函数getUpdatePoints(...)中处理
   AppConnect.getInstance(this).getPoints(this);
   super.onResume();
 }
示例#4
0
 @Override
 protected void onDestroy() {
   Intent intent = new Intent(this, MessageService.class);
   stopService(intent);
   super.onDestroy();
   // 清楚广告资源
   AppConnect.getInstance(this).close();
 }
示例#5
0
 @Override
 protected void onDestroy() {
   super.onDestroy();
   // 关闭广告
   AppConnect.getInstance(this).close();
   // System.exit(0);
   // 或者下面这种方式
   android.os.Process.killProcess(android.os.Process.myPid());
 }
示例#6
0
 public void onDestroy() {
   soundp.release();
   AppConnect.getInstance(this).close();
   super.onDestroy();
 }
示例#7
0
 /*
  * (non-Javadoc)
  *
  * @see android.app.Activity#onResume()
  */
 @Override
 protected void onResume() {
   // TODO Auto-generated method stub
   AppConnect.getInstance(this).initPopAd(this);
   super.onResume();
 };
示例#8
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home);

    sharedPreferences = getSharedPreferences("keke_player", MODE_PRIVATE);
    editor = sharedPreferences.edit();

    // 判别数据库是否变化了,仅在升级或安装后,变化一次
    if (DBversion > sharedPreferences.getInt("DBversion", 0)) {
      Log.d(LOGTAG, "===>数据库版本过旧,即将更新!");
      // 版本号比之前记录的版本号高,说明变化了
      editor.putInt("DBversion", DBversion);
      editor.putBoolean("DBChanged", true);
      // 2013-07-28, 配合backup用户自定义的收藏列表
      editor.putBoolean("needSelfDevFavbkp", true);
      editor.commit();
    }

    // 判断CPU类型,如果低于ARMV6,则不让其运行
    if (SystemUtility.getArmArchitecture() <= 6) {
      // 如果已经是硬解码模式,则无需设置
      boolean isHardDec = sharedPreferences.getBoolean("isHardDec", false);
      if (isHardDec) {
        // do nothing
      } else
        new AlertDialog.Builder(HomeActivity.this)
            .setIcon(R.drawable.ic_dialog_alert)
            .setTitle("警告")
            .setMessage("抱歉!软件解码库暂时不支持您的CPU\n\n请到设置中选择【硬解码】模式,且只能使用硬解码")
            // .setMessage("抱歉!软件解码库暂时不支持您的CPU")
            .setPositiveButton(
                "设置",
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    // do nothing - it will close on
                    // its own
                    Intent intent = new Intent();
                    // 跳转至设置界面
                    intent.setClass(HomeActivity.this, SetupActivity.class);
                    startActivity(intent);
                  }
                })
            .show();
    }

    Network network = new Network(this);
    // 判断是否打开了网络
    if (network.isOpenNetwork()) {
      // 如果连接的是移动网络,对用户作出警告
      if (network.isMobileNetwork())
        new AlertDialog.Builder(HomeActivity.this)
            .setIcon(R.drawable.ic_dialog_alert)
            .setTitle("警告")
            .setMessage("您正在使用2G/3G网络,由此产生的流量费用由网络运营商收取!\n\n是否切换至Wi-Fi网络?")
            .setPositiveButton(
                "是",
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    // do nothing - it will close on its own
                    Intent intent = null;
                    try {
                      intent =
                          new Intent(
                              // android.provider.Settings.ACTION_WIRELESS_SETTINGS);
                              // 直接跳转到WIFI网络设置
                              android.provider.Settings.ACTION_WIFI_SETTINGS);
                      startActivity(intent);
                    } catch (Exception e) {
                      Log.w(LOGTAG, "open network settings failed, please check...");
                      e.printStackTrace();
                    }
                  }
                })
            .setNegativeButton(
                "否",
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                  }
                })
            .show();
    } else {
      // 如果没有网络连接
      new AlertDialog.Builder(HomeActivity.this)
          .setIcon(R.drawable.ic_dialog_alert)
          .setTitle("没有可用的网络")
          .setMessage("推荐您只在Wi-Fi模式下观看直播电视节目!\n\n是否对Wi-Fi网络进行设置?")
          .setPositiveButton(
              "是",
              new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                  Intent intent = null;
                  try {
                    intent =
                        new Intent(
                            // android.provider.Settings.ACTION_WIRELESS_SETTINGS);
                            // 直接跳转到WIFI网络设置
                            android.provider.Settings.ACTION_WIFI_SETTINGS);
                    startActivity(intent);
                  } catch (Exception e) {
                    Log.w(LOGTAG, "open network settings failed, please check...");
                    e.printStackTrace();
                  }
                }
              })
          .setNegativeButton(
              "否",
              new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                  dialog.cancel();
                }
              })
          .show();
    }

    // 启动广告
    AppConnect.getInstance(this);

    // ========================================================
    // 2013-08-06
    // 由于新版1.3.1之后加入了积分要求在线配置的功能,所以可能会有调节功能
    // 如某段时间搞活动,要求的积分较少,过一段时间,可能要上调
    // 主要根据收益情况调整(这部分工作放到HomeActivity中去做)
    // 在线获取需要的积分参数,以便随时可以控制积分值
    String noAdPoint = AppConnect.getInstance(HomeActivity.this).getConfig("noAdPoint", "88888");
    if (sharedPreferences.getInt("pointTotal", 0) <= Integer.parseInt(noAdPoint)) {
      editor.putBoolean("noAd", false);
      editor.commit();
      Log.d(LOGTAG, "===> reset Ad mode, has ad agatin");
    }
    // ========================================================

    // 创建应用程序工作目录
    File dir = new File(Environment.getExternalStorageDirectory().getPath() + "/kekePlayer");
    if (dir.exists()) {
      /* do nothing */
    } else {
      dir.mkdirs();
    }

    findViews();
    setListensers();
  }
示例#9
0
	public void showAdDetail(final Context context, final AdInfo adInfo){
    	try {
    		final Dialog dialog = new Dialog(context, android.R.style.Theme_Translucent);
    		if(adInfo != null){
				View view = View.inflate(context, context.getResources().getIdentifier("detail", "layout", context.getPackageName()), null);
				ImageView icon = (ImageView) view.findViewById(context.getResources().getIdentifier("detail_icon", "id", context.getPackageName()));
				TextView title = (TextView) view.findViewById(context.getResources().getIdentifier("detail_title", "id", context.getPackageName()));
				TextView version = (TextView) view.findViewById(context.getResources().getIdentifier("detail_version", "id", context.getPackageName()));
				TextView filesize = (TextView) view.findViewById(context.getResources().getIdentifier("detail_filesize", "id", context.getPackageName()));
				Button downButton1 = (Button) view.findViewById(context.getResources().getIdentifier("detail_downButton1", "id", context.getPackageName()));
				TextView content = (TextView) view.findViewById(context.getResources().getIdentifier("detail_content", "id", context.getPackageName()));
				TextView description = (TextView) view.findViewById(context.getResources().getIdentifier("detail_description", "id", context.getPackageName()));
				ImageView image1 = (ImageView) view.findViewById(context.getResources().getIdentifier("detail_image1", "id", context.getPackageName()));
				ImageView image2 = (ImageView) view.findViewById(context.getResources().getIdentifier("detail_image2", "id", context.getPackageName()));
				Button downButton2 = (Button) view.findViewById(context.getResources().getIdentifier("detail_downButton2", "id", context.getPackageName()));
				
				icon.setImageBitmap(adInfo.getAdIcon());
				icon.setScaleType(ImageView.ScaleType.FIT_CENTER);
				title.setText(adInfo.getAdName());
				title.setTextSize(17);
				version.setText("  "+adInfo.getVersion());
				filesize.setText("  "+adInfo.getFilesize()+"M");
				content.setText(adInfo.getAdText());
				description.setText(adInfo.getDescription());
				
				new GetImagesTask(context, adInfo, image1, image2).execute();
			
				downButton1.setOnClickListener(new OnClickListener() {
					public void onClick(View v) {
						AppConnect.getInstance(context).downloadAd(context, adInfo.getAdId());
						if(dialog != null){
							dialog.cancel();
						}
					}
				});
				downButton2.setOnClickListener(new OnClickListener() {
					public void onClick(View v) {
						AppConnect.getInstance(context).downloadAd(context, adInfo.getAdId());
						if(dialog != null){
							dialog.cancel();
						}
					}
				});
			
				int bg_img = context.getResources().getIdentifier("detail_bg", "drawable", context.getPackageName());
				
				if(bg_img != 0){
					view.setBackgroundResource(bg_img);
				}else{
					view.setBackgroundResource(android.R.drawable.editbox_background);
				}
				
				LinearLayout layout = new LinearLayout(context);
				layout.setGravity(Gravity.CENTER);
				layout.setId(1);
				
				// 对小屏手机进行屏幕判断
				int displaySize = SDKUtils.getDisplaySize(context);
				if(displaySize == 320){
					layout.setPadding(15, 15, 15, 15);
				}else if(displaySize == 240){
					layout.setPadding(10, 10, 10, 10);
				}else{
					layout.setPadding(20, 20, 20, 20);
				}
				
				layout.setBackgroundColor(Color.argb(200, 10, 10, 10));
				
				layout.addView(view);
				
				dialog.setContentView(layout);
				dialog.show();
			}
			
		} catch (Exception e) {
			e.printStackTrace();
			AppConnect.getInstance(context).clickAd(context, adInfo.getAdId());
		}
    }