Android隱藏廣告+指定日期運行程序

package lawdaquan.co.cc;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import net.miidi.credit.IAuxiliaryNotifier;
import net.miidi.credit.IOffersNotifier;
import net.miidi.credit.MiidiCredit;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

public class LawdaquanActivity extends Activity implements IOffersNotifier,
  IAuxiliaryNotifier {
 private ImageView mImageView9;
 private TextView mTextView9;
 Handler mHandler;

 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);
  MiidiCredit.init(this, "4610", "9kub15589v2d35xw", false);
  setContentView(R.layout.main);

  ImageView mImageView1 = (ImageView) findViewById(R.id.imageView1);
  ImageView mImageView2 = (ImageView) findViewById(R.id.imageView2);
  ImageView mImageView3 = (ImageView) findViewById(R.id.imageView3);
  ImageView mImageView4 = (ImageView) findViewById(R.id.imageView4);
  ImageView mImageView5 = (ImageView) findViewById(R.id.imageView5);
  ImageView mImageView6 = (ImageView) findViewById(R.id.imageView6);
  ImageView mImageView7 = (ImageView) findViewById(R.id.imageView7);
  ImageView mImageView8 = (ImageView) findViewById(R.id.imageView8);
  mImageView1.setOnClickListener(onclicklistener1);
  mImageView2.setOnClickListener(onclicklistener2);
  mImageView3.setOnClickListener(onclicklistener3);
  mImageView4.setOnClickListener(onclicklistener4);
  mImageView5.setOnClickListener(onclicklistener5);
  mImageView6.setOnClickListener(onclicklistener6);
  mImageView7.setOnClickListener(onclicklistener7);
  mImageView8.setOnClickListener(onclicklistener8);

  mImageView9 = (ImageView) findViewById(R.id.imageView9);
  mTextView9 = (TextView) findViewById(R.id.textView9);
  // SimpleDateFormat sdfTime = new
  // SimpleDateFormat("yyyy-MM-dd,hh:mm:ss");
  //
  // String nowTime = sdfTime.format(new Date());
  // StringBuffer sba = new StringBuffer();
  // String astartTime = startTime.substring(0, 2);

  // java.util.Date nowdate = new java.util.Date();
  // String myString = "2008-09-08";
  // SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd",
  // Locale.CHINA);
  // try {
  // Date d = sdf.parse(myString);
  // } catch (ParseException e) {
  // // TODO Auto-generated catch block
  // e.printStackTrace();
  // }
  // // boolean flag = d.before(nowdate);
  // String s1 = "2012-5-25 04:40:09";
  // String s2="2008-01-29 09:12:11";
  //
  // java.text.DateFormat df = new java.text.SimpleDateFormat(
  // "yyyy-MM-dd HH:mm:ss");
  // java.util.Calendar c1 = java.util.Calendar.getInstance();
  // java.util.Calendar c2 = java.util.Calendar.getInstance();
  // try {
  // c1.setTime(df.parse(s1));
  // c2.setTime(df.parse(s2));
  //
  // } catch (Exception e) {
  // // TODO: handle exception
  // }
  // int result=c1.compareTo(c2);
  // if (result>) {
  //
  // }

  String s1 = "2012-5-28 12:00:00";

  // SimpleDateFormat formatter = new
  // SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  SimpleDateFormat sDateFormat = new SimpleDateFormat(
    "yyyy-MM-dd hh:mm:ss");
  String date = sDateFormat.format(new java.util.Date());

  // String str = formatter.format(curDate);

  DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  Calendar c1 = Calendar.getInstance();
  Calendar str = Calendar.getInstance();
  try {
   c1.setTime(df.parse(s1));
   str.setTime(df.parse(date));

  } catch (Exception e) {
   // TODO: handle exception
  }

  int result = c1.compareTo(str);
  // if (result == 0)
  // System.out.println("當前時間等於系統時間");
  if (result < 0) {
   System.out.println("當前時間小於系統時間");
   mImageView9.setVisibility(View.VISIBLE);
   mTextView9.setVisibility(View.VISIBLE);

  } else {
   System.out.println("當前時間大於系統時間");
   mImageView9.setVisibility(View.INVISIBLE);
   mTextView9.setVisibility(View.INVISIBLE);

  }

  // mTextView9.setText(str);

  mImageView9.setOnClickListener(onclicklistener9);

 
  // if (str-oooString) {
  //
  // mImageView9.setVisibility(View.VISIBLE);
  //
  // }

  MiidiCredit.setOffersListener(this);
  MiidiCredit.setAuxiliaryListener(this);

 }

 private OnClickListener onclicklistener9 = new OnClickListener() {

  @Override
  public void onClick(View v) {
   // TODO Auto-generated method stub
   MiidiCredit.showAppOffers();

  }
 };

 private OnClickListener onclicklistener1 = new OnClickListener() {

  @Override
  public void onClick(View v) {
   // TODO Auto-generated method stub
   Intent intent1 = new Intent(LawdaquanActivity.this, xingfa.class);
   startActivity(intent1);

  }
 };

 private OnClickListener onclicklistener2 = new OnClickListener() {

  @Override
  public void onClick(View v) {
   // TODO Auto-generated method stub
   Intent intent2 = new Intent(LawdaquanActivity.this, minfa.class);
   startActivity(intent2);

  }
 };

 private OnClickListener onclicklistener3 = new OnClickListener() {

  @Override
  public void onClick(View v) {
   // TODO Auto-generated method stub
   Intent intent3 = new Intent(LawdaquanActivity.this, chufa.class);
   startActivity(intent3);

  }
 };

 private OnClickListener onclicklistener4 = new OnClickListener() {

  @Override
  public void onClick(View v) {
   // TODO Auto-generated method stub
   Intent intent4 = new Intent(LawdaquanActivity.this, xingsu.class);
   startActivity(intent4);

  }
 };

 private OnClickListener onclicklistener5 = new OnClickListener() {

  @Override
  public void onClick(View v) {
   // TODO Auto-generated method stub
   Intent intent5 = new Intent(LawdaquanActivity.this, minsu.class);
   startActivity(intent5);

  }
 };

 private OnClickListener onclicklistener6 = new OnClickListener() {

  @Override
  public void onClick(View v) {
   // TODO Auto-generated method stub
   Intent intent6 = new Intent(LawdaquanActivity.this, xinsu.class);
   startActivity(intent6);

  }
 };

 private OnClickListener onclicklistener7 = new OnClickListener() {

  @Override
  public void onClick(View v) {
   // TODO Auto-generated method stub
   Intent intent7 = new Intent(LawdaquanActivity.this, wenshu.class);
   startActivity(intent7);

  }
 };

 private OnClickListener onclicklistener8 = new OnClickListener() {

  @Override
  public void onClick(View v) {
   // TODO Auto-generated method stub
   Intent intent8 = new Intent(LawdaquanActivity.this, xianfa.class);
   startActivity(intent8);

  }
 };

 public boolean onCreateOptionsMenu(Menu menu) {
  // TODO Auto-generated method stub
  menu.add("關於");
  return super.onCreateOptionsMenu(menu);
 }

 public boolean onOptionsItemSelected(MenuItem item) {
  // TODO Auto-generated method stub
  new AlertDialog.Builder(this).setTitle("法律大全")
    .setMessage(getString(R.string.about))
    .setPositiveButton("關閉", null).show();
  return super.onOptionsItemSelected(item);

 }

 public void onBackPressed() {
  AlertDialog.Builder builder = new Builder(LawdaquanActivity.this);
  builder.setIcon(R.drawable.imagebutton5);
  builder.setTitle("提示");
  builder.setMessage("你真的要退出法律信息軟件嗎?");
  builder.setPositiveButton("是",
    new android.content.DialogInterface.OnClickListener() {
     @Override
     public void onClick(DialogInterface dialog, int which) {
      dialog.dismiss();
      android.os.Process.killProcess(android.os.Process
        .myPid());

     }
    });
  builder.setNegativeButton("否",
    new android.content.DialogInterface.OnClickListener() {
     @Override
     public void onClick(DialogInterface dialog, int which) {
      dialog.dismiss();
     }
    });
  builder.create().show();

 }

 @Override
 public void onChannelIdCb(int arg0) {
  // TODO Auto-generated method stub

 }

 @Override
 public void onSdkVersionCb(String arg0) {
  // TODO Auto-generated method stub

 }

 @Override
 public void onShowAppsFinishCb() {
  // TODO Auto-generated method stub

 }

 @Override
 public void onUpdatePointsCb(String arg0, int arg1) {
  // TODO Auto-generated method stub

 }

}

 

 

摘自 gongzibai的專欄

發佈留言