예제 #1
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);
    AdRequest ar = new AdRequest();
    ar.addTestDevice("4B605421C6EAA120E18B7FA165D2E980");

    final ListView lv1 = (ListView) findViewById(R.id.listView);
    threadArray = new ArrayList<String>();
    authorArray = new ArrayList<String>();

    getDevice();

    lv1.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> a, View v, int position, long id) {
            Object o = lv1.getItemAtPosition(position);
            TitleResults fullObject = (TitleResults) o;
            threadTitle = fullObject.getItemName();
            Constants.THREADURL = threadArray.get(position);
            Intent intent = new Intent(MainActivity.this, ThreadActivity.class);
            Bundle b = new Bundle();
            b.putString("title", threadTitle);
            intent.putExtras(b);
            startActivity(intent);
          }
        });

    if (Constants.DEVICE != null) {
      ArrayList<TitleResults> titleArray = getTitles();
      lv1.setAdapter(new TitleAdapter(this, titleArray));
    }
  }
  /**
   * 広告の表示
   *
   * @param dtoMap
   */
  protected void showAdView(Map dtoMap) {

    try {

      AdView adView =
          new AdView(this, AdSize.BANNER, getResources().getString(R.string.mediation_id));

      // レイアウトに配置。レイアウトには android:id="@+id/admob" の属性。
      LinearLayout layout = (LinearLayout) findViewById(R.id.ad);
      layout.removeAllViews();
      layout.addView(adView);

      final String CUSTOM_EVENT_LABEL = "MyCustomEventLabel";
      // 広告をリクエストする。エミュレータとテスト端末ではテストモードを使用する。
      AdRequest adRequest = new AdRequest();
      CustomEventExtras extras = new CustomEventExtras();
      extras.addExtra("Map", dtoMap);
      extras.addExtra(CUSTOM_EVENT_LABEL, "hello custom event");
      adRequest.setNetworkExtras(extras);
      Set<String> keywords = new HashSet<String>();
      keywords.add(String.valueOf(dtoMap.adType));
      keywords.add(dtoMap.adCode01);
      keywords.add(dtoMap.adCode02);
      adRequest.addKeywords(keywords);

      adView.loadAd(adRequest);

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
예제 #3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    adView = new AdView(this, AdSize.SMART_BANNER, "a152f84b0f4f9ed");
    LinearLayout adContainer = (LinearLayout) this.findViewById(R.id.adsContainer);
    adContainer.addView(adView);

    AdRequest adRequest = new AdRequest();
    Set<String> keywordsSet = new HashSet<String>();
    keywordsSet.add("game");
    keywordsSet.add("dating");
    keywordsSet.add("money");
    keywordsSet.add("girl");
    adRequest.addKeywords(keywordsSet);
    adRequest.addTestDevice("1B91DF7A13E674202332C251084C3ADA");
    adView.loadAd(adRequest);

    imageView = (ImageView) this.findViewById(R.id.imageView1);

    progressDialog = new ProgressDialog(this);
    progressDialog.setTitle("Download Image");
    progressDialog.setMessage("Downloading in progress...");
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setProgress(0);
    progressDialog.setButton(
        DialogInterface.BUTTON_NEGATIVE, "Show Image", dialogInterfaceOnClickListener);

    Button downloadButton = (Button) findViewById(R.id.downloadButton);
    downloadButton.setOnClickListener(downloadButtonOnClickListener);
  }
 private void createAdView() {
   adView = new AdView(this, AdSize.BANNER, AdMob_Ad_Unit);
   LinearLayout layout = (LinearLayout) findViewById(R.id.mainLinear);
   layout.addView(adView, 0);
   AdRequest request = new AdRequest();
   request.addTestDevice(request.TEST_EMULATOR);
   request.addTestDevice("00194a163e3f5e");
   adView.loadAd(request);
 }
예제 #5
0
 private void admobs() {
   AdView adview = (AdView) findViewById(R.id.adView);
   AdRequest request = new AdRequest();
   request.addTestDevice(AdRequest.TEST_EMULATOR);
   //		String imei = AndroidUtils.getIMEI(this);
   // nexus s
   request.addTestDevice("355031040408409");
   // request.addKeyword("android");
   // request.addKeyword("game");
   adview.loadAd(request);
 }
  /**
   * Interface called by the AN SDK to request an ad from the mediating SDK.
   *
   * @param mBC the object which will be called with events from the 3d party SDK
   * @param activity the activity from which this is launched
   * @param parameter String parameter received from the server for instantiation of this object
   * @param adUnitID The 3rd party placement , in adMob this is the adUnitID
   * @param width Width of the ad
   * @param height Height of the ad
   */
  @Override
  public View requestAd(
      MediatedBannerAdViewController mBC,
      Activity activity,
      String parameter,
      String adUnitID,
      int width,
      int height,
      TargetingParameters targetingParameters) {
    adListener = new AdMobAdListener(mBC, super.getClass().getSimpleName());
    adListener.printToClog(
        String.format(" - requesting an ad: [%s, %s, %dx%d]", parameter, adUnitID, width, height));

    admobAV = new AdView(activity, new AdSize(width, height), adUnitID);
    admobAV.setAdListener(adListener);
    AdRequest ar = new AdRequest();

    switch (targetingParameters.getGender()) {
      case UNKNOWN:
        break;
      case FEMALE:
        ar.setGender(AdRequest.Gender.FEMALE);
        break;
      case MALE:
        ar.setGender(AdRequest.Gender.MALE);
        break;
    }
    AdMobAdapterExtras extras = new AdMobAdapterExtras();
    if (targetingParameters.getAge() != null) {
      extras.addExtra("Age", targetingParameters.getAge());
    }

    for (Pair<String, String> p : targetingParameters.getCustomKeywords()) {
      extras.addExtra(p.first, p.second);
    }
    if (targetingParameters.getLocation() != null) {
      ar.setLocation(targetingParameters.getLocation());
    }
    ar.setNetworkExtras(extras);

    admobAV.loadAd(ar);
    return admobAV;
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    // Lookup R.layout.main
    LinearLayout layout = (LinearLayout) findViewById(R.id.admoblayout);

    // Create the adView
    // Please replace MY_BANNER_UNIT_ID with your AdMob Publisher ID
    AdView adView = new AdView(this, AdSize.BANNER, "a14e9304811c39d");

    // Add the adView to it
    layout.addView(adView);

    // Initiate a generic request to load it with an ad
    AdRequest request = new AdRequest();
    request.setTesting(true);

    adView.loadAd(request);
    position = 0;
    imgView = (ImageView) findViewById(R.id.ImageView01);
    imgView.setImageResource(Imgid[0]);

    gallery = (Gallery) findViewById(R.id.liquidgallery);
    gallery.setAdapter(new AddImgAdp(this));

    gallery.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(
              @SuppressWarnings("rawtypes") AdapterView parent, View v, int position, long id) {
            imgView.setImageResource(Imgid[position]);
            LiquidBackgroundsFreeActivity.this.position = position;
          }
        });

    imgView.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {

            AlertDialog alertDialog =
                new AlertDialog.Builder(LiquidBackgroundsFreeActivity.this).create();
            alertDialog.setTitle(Messages.getString("DIA_NUM.0")); // $NON-NLS-1$
            alertDialog.setMessage(Messages.getString("DIA_NUM.1")); // $NON-NLS-1$
            alertDialog.setButton(
                Messages.getString("DIA_NUM.2"), // $NON-NLS-1$
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {

                    Bitmap bitmap = BitmapFactory.decodeResource(getResources(), Imgid[position]);
                    try {
                      LiquidBackgroundsFreeActivity.this.setWallpaper(bitmap);
                    } catch (IOException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                    }
                    Log.d(
                        Messages.getString("DIA_NUM.3"),
                        Messages.getString("DIA_NUM.4")); // $NON-NLS-1$ //$NON-NLS-2$
                  }
                });

            alertDialog.show();
            return true;
          }
        });
  }
예제 #8
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.chart);

    // request TEST ads to avoid being disabled for clicking your own ads
    AdRequest adRequest = new AdRequest();

    // test mode on EMULATOR
    adRequest.addTestDevice(AdRequest.TEST_EMULATOR);

    // test mode on DEVICE (this example code must be replaced with your device uniquq ID)
    adRequest.addTestDevice("MB120RT82011");
    adRequest.addTestDevice("TA23703EIP");

    adView = (AdView) findViewById(R.id.adMob);

    // Wenn ein TrackingService läuft, soll der Zugriff auf die Datenbank unterbunden werden, da
    // es sonst zu einem Programmabsturz kommt.
    if (RouteTrackingDialog.isMyServiceRunning(
        "de.myge.routetracking.GpsTrackingService", getApplicationContext())) {
      ErrorHandling.showError(
          getApplicationContext(), getResources().getString(R.string.error_visualise_routes));
    } else {
      // Datenbankzugriff holen, damit das Geschwindigkeitschart zu einem Profil geladen werden kann
      db = new CreateDatabase(this);

      // Spinner initialisieren. Dieser Spinner dient der Auswahl der getrackten Routen.
      final Spinner spinner = (Spinner) findViewById(R.id.routes_charts);

      spinner.setOnItemSelectedListener(
          new OnItemSelectedListener() {

            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
              String item = (String) parent.getItemAtPosition(pos);

              // Index ist die ID des Profils, das Ausgewählt wurde
              int index = 0;
              for (int i = 0; i < profiles.size(); i++) {
                if (profiles.get(i).getProfileName().equals(item)) {
                  index = profiles.get(i).getId();
                  break;
                }
              }

              List<GpsCoordinates> gpsCoord;
              try {
                //					gpsCoord = db.getCoordinatesDao().queryBuilder().where().eq("profile_id",
                // index).query();
                QueryBuilder<GpsCoordinates, Integer> qb = db.getCoordinatesDao().queryBuilder();
                qb.where().eq("profile_id", index);
                qb.orderBy("timestamp", true);
                gpsCoord = qb.query();
                if (gpsCoord.size() > 0) {
                  ArrayList<GraphViewData> graphViewData = new ArrayList<GraphView.GraphViewData>();
                  for (int i = 0; i < gpsCoord.size(); i++) {
                    if (de.myge.routetracking.settings.Settings.getInstance(ChartActivity.this)
                        .isSpeedInKmh()) {
                      graphViewData.add(new GraphViewData(i, gpsCoord.get(i).getSpeed() * 3.6f));
                    } else {
                      graphViewData.add(
                          new GraphViewData(i, gpsCoord.get(i).getSpeed() * 3.6f * 0.6213712f));
                    }
                  }

                  // init example series data
                  GraphViewSeries exampleSeries =
                      new GraphViewSeries(
                          graphViewData.toArray(new GraphViewData[graphViewData.size()]));

                  GraphView graphView =
                      new LineGraphView(
                          ChartActivity.this // context
                          ,
                          item // heading
                          );

                  Date start = gpsCoord.get(0).getTimestamp();
                  Date end = gpsCoord.get(gpsCoord.size() - 1).getTimestamp();

                  SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy hh:mm");

                  graphView.setHorizontalLabels(new String[] {sdf.format(start), sdf.format(end)});

                  graphView.addSeries(exampleSeries);
                  graphView.setScrollable(true);
                  graphView.setScalable(true);
                  LinearLayout layout = (LinearLayout) findViewById(R.id.chartLayout);
                  layout.removeAllViews();
                  layout.addView(spinner);
                  layout.addView(graphView);
                }
              } catch (SQLException e) {
                ErrorHandling.showError(getApplicationContext(), e);
              }
            }

            @Override
            public void onNothingSelected(AdapterView<?> arg0) {
              // TODO Auto-generated method stub

            }
          });

      try {
        // Alle Routen auflisten
        profiles = db.getProfileCoordinatesDao().queryForAll();
        // Routennamen in ein Array packen, damit die Routennamen dem Spinner zur Auwahl übergeben
        // werden können
        String profileNames[] = new String[profiles.size()];
        for (int i = 0; i < profiles.size(); i++) {
          profileNames[i] = profiles.get(i).getProfileName();
        }

        ArrayAdapter<String> adapter =
            new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, profileNames);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter);
      } catch (SQLException e) {
        ErrorHandling.showError(getApplicationContext(), e);
      }
    }
  }