lundi 29 septembre 2014

Get an error while i try to put Insterstitial Ads


Vote count:

0




i ask here because i can't put instertital ads in my app. I get like 20 errors when i put the code below the saved Instance. I had other app and i never had problems, but now i just can't.


In the section of Toast (below ad code) i get this error: Multiple markers at this line - Syntax error on token "(", invalid VariableDeclaratorId - Syntax error on tokens, delete these tokens - Syntax error on token "makeText", Identifier expected after this token - Syntax error on token ")", delete this token


Below toast, on btnSwitch i get this errors: Multiple markers at this line - Return type for the method is missing - Syntax error on token ".", ... expected - Syntax error on token ")", { expected after this token - Syntax error on token "btnSwitch", VariableDeclaratorId expected after this token - Syntax error, insert ";" to complete FieldDeclaration


package lol.flashlight;


Then here:



ImageView Facebook = (ImageView) findViewById(R.id.imageView3);
Facebook.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {


i get this errors: Multiple markers at this line - Syntax error, insert "}" to complete MethodBody - Syntax error, insert ")" to complete Expression - Syntax error, insert ";" to complete Statement - Syntax error, insert "}" to complete ClassBody


...I get MORE errors I tried to put it at the final but anyway i get these errors, what can i do? I let my full code if u wanna check:



import com.google.ads.Ad;
import com.google.ads.AdListener;
import com.google.ads.AdRequest;
import com.google.ads.AdRequest.ErrorCode;
import com.google.ads.InterstitialAd;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.hardware.Camera;
import android.hardware.Camera.Parameters;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity implements AdListener {

ImageView btnSwitch;

private Camera camera;
private boolean isFlashOn;
private boolean hasFlash;
Parameters params;
MediaPlayer mp;

private InterstitialAd interstitial;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// Create the interstitial
interstitial = new InterstitialAd(this, "fgfgfgfgfgfgfgfgfgfgfgfgfgfgfgfgfgfgfgfgfgfgfgfgfgfgfgfgfg");

// Create ad request
AdRequest adRequest = new AdRequest();

// Begin loading your interstitial
interstitial.loadAd(adRequest);

// Set Ad Listener to use the callbacks below
interstitial.setAdListener(this);
}

@Override
public void onReceiveAd(Ad ad) {
Log.d("OK", "Received ad");
if (ad == interstitial) {
interstitial.show();
}
}

@Override
public void onDismissScreen(Ad arg0) {
// TODO Auto-generated method stub

}

@Override
public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
// TODO Auto-generated method stub

}

@Override
public void onLeaveApplication(Ad arg0) {
// TODO Auto-generated method stub

}

@Override
public void onPresentScreen(Ad arg0) {
// TODO Auto-generated method stub

}




Toast.makeText(MainActivity.this, "Touch amumu's body to play a sound!", Toast.LENGTH_SHORT).show();

// flash switch button
btnSwitch = (ImageView) findViewById(R.id.imageView1);


// First check if device is supporting flashlight or not
hasFlash = getApplicationContext().getPackageManager()
.hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);

if (!hasFlash) {
// device doesn't support flash
// Show alert message and close the application
AlertDialog alert = new AlertDialog.Builder(MainActivity.this)
.create();
alert.setTitle("Error");
alert.setMessage("Sorry, your device doesn't support flash light!");
alert.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// closing the application
finish();
}
});
alert.show();
return;
}


getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);


ImageView Facebook = (ImageView) findViewById(R.id.imageView3);
Facebook.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
mp = MediaPlayer.create(MainActivity.this, R.raw.draven);

mp.setOnCompletionListener(new OnCompletionListener() {

@Override
public void onCompletion(MediaPlayer mp) {
// TODO Auto-generated method stub
mp.release();
}
});

mp.start();

Intent facebookIntent = new Intent(Intent.ACTION_SEND);
facebookIntent.setType("text/plain");
facebookIntent.setPackage("com.facebook.katana");
facebookIntent.putExtra(Intent.EXTRA_TEXT, "http://ift.tt/1rA6LqQ");
startActivity(facebookIntent);

}});



ImageView Twitter = (ImageView) findViewById(R.id.imageView4);
Twitter.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mp = MediaPlayer.create(MainActivity.this, R.raw.draven);

mp.setOnCompletionListener(new OnCompletionListener() {

@Override
public void onCompletion(MediaPlayer mp) {
// TODO Auto-generated method stub
mp.release();
}
});

mp.start();
//al apretar click en el boton Ir a Web abre el browser con la pág: google.com
Intent browserIntent =
new Intent(Intent.ACTION_VIEW,
Uri.parse("http://ift.tt/1qPTl5a!"));
startActivity(browserIntent);




}});

//OnClick del View :D
ImageView Ez = (ImageView) findViewById(R.id.imageView2);
Ez.setOnClickListener(new OnClickListener(){

public void onClick(View v) {
// TODO Auto-generated method stub

mp = MediaPlayer.create(MainActivity.this, R.raw.amumu);

mp.setOnCompletionListener(new OnCompletionListener() {

@Override
public void onCompletion(MediaPlayer mp) {
// TODO Auto-generated method stub
mp.release();
}
});

mp.start();
}});




//OnClick del View :D
// ImageView Mundo = (ImageView) findViewById(R.id.imageView6);
// Mundo.setOnClickListener(new OnClickListener(){

// public void onClick(View v) {
// TODO Auto-generated method stub
//
// mp = MediaPlayer.create(MainActivity.this, R.raw.mundo);

//mp.setOnCompletionListener(new OnCompletionListener() {

// @Override
// public void onCompletion(MediaPlayer mp) {
// TODO Auto-generated method stub
// mp.release();
// }
// });

// mp.start();
//}});




//OnClick del View :D
// ImageView Orianna = (ImageView) findViewById(R.id.imageView7);
// Orianna.setOnClickListener(new OnClickListener(){

//public void onClick(View v) {
// TODO Auto-generated method stub

// mp = MediaPlayer.create(MainActivity.this, R.raw.orianna);

// mp.setOnCompletionListener(new OnCompletionListener() {

// @Override
// public void onCompletion(MediaPlayer mp) {
// TODO Auto-generated method stub
// mp.release();
// }
// });

// mp.start();
//}});





// get the camera
getCamera();

// displaying button image
toggleButtonImage();


// Switch button click event to toggle flash on/off
btnSwitch.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
if (isFlashOn) {
// turn off flash
turnOffFlash();
} else {
// turn on flash
turnOnFlash();
}
}
});
}


// Get the camera
private void getCamera() {
if (camera == null) {
try {
camera = Camera.open();
params = camera.getParameters();
} catch (RuntimeException e) {
Log.e("Camera Error. Failed to Open. Error: ", e.getMessage());
}
}
}


// Turning On flash
private void turnOnFlash() {
if (!isFlashOn) {
if (camera == null || params == null) {
return;
}
// play sound
playSound();

params = camera.getParameters();
params.setFlashMode(Parameters.FLASH_MODE_TORCH);
camera.setParameters(params);
camera.startPreview();
isFlashOn = true;

// changing button/switch image
toggleButtonImage();
}

}


// Turning Off flash
private void turnOffFlash() {
if (isFlashOn) {
if (camera == null || params == null) {
return;
}
// play sound
playSound();

params = camera.getParameters();
params.setFlashMode(Parameters.FLASH_MODE_OFF);
camera.setParameters(params);
camera.stopPreview();
isFlashOn = false;

// changing button/switch image
toggleButtonImage();
}
}


// Playing sound
// will play button toggle sound on flash on / off
private void playSound(){
if(isFlashOn){
mp = MediaPlayer.create(MainActivity.this, R.raw.playbutton);
}else{
mp = MediaPlayer.create(MainActivity.this, R.raw.rayo);
}
mp.setOnCompletionListener(new OnCompletionListener() {

@Override
public void onCompletion(MediaPlayer mp) {
// TODO Auto-generated method stub
mp.release();
}
});
mp.start();
}

/*
* Toggle switch button images
* changing image states to on / off
* */
private void toggleButtonImage(){
if(isFlashOn){
btnSwitch.setImageResource(R.drawable.on);
}else{
btnSwitch.setImageResource(R.drawable.off);
}
}

@Override
protected void onDestroy() {
super.onDestroy();

}

@Override
protected void onPause() {
super.onPause();

// on pause turn off the flash
turnOffFlash();

}

@Override
protected void onRestart() {
super.onRestart();
}

@Override
protected void onResume() {
super.onResume();

}

@Override
protected void onStart() {
super.onStart();

// on starting the app get the camera params
getCamera();
}

@Override
protected void onStop() {
super.onStop();

// on stop release the camera
if (camera != null) {
camera.release();
camera = null;


}


}




}


asked 5 mins ago







Get an error while i try to put Insterstitial Ads

Aucun commentaire:

Enregistrer un commentaire