Example #1
0
  /** @description function to display the previous exam score of the user. */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(com.raulgupta.exam.R.layout.activity_view_test_score);
    score = (TextView) findViewById(com.raulgupta.exam.R.id.textView2);
    StringBuffer sb = new StringBuffer("\n");
    if (getIntent().getExtras().containsKey("score")
        && getIntent().getExtras().containsKey("test_Name")) {
      String[] allScore = getIntent().getExtras().getStringArray("score");
      String[] allTest = getIntent().getExtras().getStringArray("test_Name");

      // score.setText("Score : "+getIntent().getExtras().getString("score") + " %");
      sb.append("Score\n");
      for (int i = 0; i < 3; i++) {
        if (allScore[i] != null && allTest[i] != null) {
          sb.append(allTest[i].toUpperCase() + " : ");
          sb.append(allScore[i]);
        }
        sb.append("\n");
      }
      score.setText(sb);
      score.setTextColor(Color.BLACK);
    }
    if (getIntent().getExtras().containsKey("score")
        && getIntent().getExtras().containsKey("user_Name")) {
      String[] allScore = getIntent().getExtras().getStringArray("score");
      String[] allTest = getIntent().getExtras().getStringArray("user_Name");
      String[] allCountry = getIntent().getExtras().getStringArray("country");
      // score.setText("Score : "+getIntent().getExtras().getString("score") + " %");
      sb.append("LeaderBoard\n");
      for (int i = 0; i < 5; i++) {
        if (allScore[i] != null && allTest[i] != null) {
          sb.append(allTest[i].toUpperCase() + " : ");
          sb.append(allScore[i] + " : ");
          sb.append(allCountry[i]);
        }
        sb.append("\n");
      }
      score.setTextSize(20);
      score.setText(sb);
      score.setTextColor(Color.BLACK);
    }

    MobileAds.initialize(getApplicationContext(), "ca-app-pub-5127965163149320~6624066694");
    AdView mAdView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
  } // end of onCreate()
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    MobileAds.initialize(getApplicationContext(), "ca-app-pub-7818455682102414~3747009689");
    mInterstitialAd = new InterstitialAd(this);
    mInterstitialAd.setAdUnitId("ca-app-pub-7818455682102414/8273221287");

    mInterstitialAd.setAdListener(
        new AdListener() {
          @Override
          public void onAdClosed() {
            Log.d("YellowAndDangerous", "onAdClosed");
            requestNewInterstitial();
            showingAd = false;
          }
        });

    requestNewInterstitial();
  }
Example #3
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mContext = this.getApplicationContext();
    Resources mResources = this.getResources();
    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);

    /* mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    // Register NMEA listener
    if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        int TAG_CODE_PERMISSION_FINE_LOCATION = 1;
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, TAG_CODE_PERMISSION_FINE_LOCATION);
        return;
    }

    if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
        createNmeaListener();
        // mLocationManager.addNmeaListener(mNmeaListener);
    }*/

    // Launch Sntp request
    createSntp();

    setContentView(R.layout.main);

    // AdMob
    MobileAds.initialize(getApplicationContext(), getString(R.string.ad_unit_id));
    AdView adView = (AdView) this.findViewById(R.id.adView);
    AdRequest adRequest =
        new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            //                .addTestDevice("53356E870D99B80A68F8E2DBBFCD28FB")
            .build();
    adView.loadAd(adRequest);

    mViewSwitcher = (ViewSwitcher) findViewById(R.id.profileSwitcher);

    // Get Preferences
    PreferenceManager.setDefaultValues(this, R.xml.setting, false);
    myCountry = mSharedPreferences.getInt(MY_COUNTRY, -1);

    countries = mResources.getStringArray(R.array.countries);
    flags = mResources.obtainTypedArray(R.array.flags);
    sounds = mResources.obtainTypedArray(R.array.sounds);

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

    gallery.setOnItemClickListener(
        new OnItemClickListener() {
          public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            setMyFlag(position);
          }
        });

    if (myCountry >= 0) setMyFlag(myCountry);

    // Display change log if new version
    ChangeLog cl = new ChangeLog(this);
    if (cl.firstRun())
      new HtmlAlertDialog(
              this,
              R.raw.about,
              getString(R.string.about_title),
              android.R.drawable.ic_menu_info_details)
          .show();

    // Audio management for initVolume control
    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    // Propose to set initVolume to max if it is not loud enough
    initVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
    int maxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
    if (mSharedPreferences.getBoolean(CHECK_VOLUME, false)) {
      if ((2 * initVolume / maxVolume) < 1) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.volume_title);
        builder.setIcon(android.R.drawable.ic_menu_preferences);
        builder.setMessage(R.string.volume_question);
        builder.setNegativeButton(R.string.volume_no, null);
        builder.setPositiveButton(
            R.string.volume_yes,
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                mAudioManager.setStreamVolume(
                    AudioManager.STREAM_MUSIC,
                    mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC),
                    AudioManager.FLAG_SHOW_UI);
              }
            });
        builder.create();
        builder.show();
      }
    } else {
      if (mSharedPreferences.getBoolean(VOLUME_MAX, false)) {
        mAudioManager.setStreamVolume(
            AudioManager.STREAM_MUSIC,
            mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC),
            AudioManager.FLAG_SHOW_UI);
      }
    }
  }