I tried to add the Leadbolt "App wall" into my but its not showing.
I did it like the documentation explains it.
Heres my MainActivity.java
package com.NAME.APP;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import com.NAME.APP.R;
import com.SDKPACKAGE.AdController;
import com.appfireworks.android.track.AppTracker;
import android.content.Context;
import android.content.Intent;
import com.SDKPACKAGE.AdBootReceiver;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
public class BootReceiver extends AdBootReceiver {
public void onReceive(Context ctx, Intent intent) {
intent.putExtra("sectionid","MY ID");
super.onReceive(ctx, intent);
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); //Set the screen's view to your xml file
Button button1 = (Button) findViewById(R.id.button1); // Retrieve the button from the XML file
button1.setOnClickListener(new View.OnClickListener() { //Add a listener for when the button is pressed
@Override
public void onClick(View v) {
sendToTwitter();
}
});
}
protected void sendToTwitter() {
String url = "MY URL"; // You could have this at the top of the class as a constant, or pass it in as a method variable, if you wish to send to multiple websites
Intent i = new Intent(Intent.ACTION_VIEW); // Create a new intent - stating you want to 'view something'
i.setData(Uri.parse(url)); // Add the url data (allowing android to realise you want to open the browser)
startActivity(i); // Go go go!
}
private AdController ad;
public void onCreate11(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ad = new AdController(this, "MY ID");
ad.loadStartAd("MY_LB_AUDIO_ID", "MY ID");
AppTracker.startSession(this, "APPFIREWORKS_API_KEY");
}
@Override
public void onPause() {
super.onPause();
if(ad != null) {
ad.destroyAd();
}
if(!isFinishing()) {
AppTracker.pause(getApplicationContext());
}
}
@Override
public void onResume() {
super.onResume();
AppTracker.resume(getApplicationContext());
}
public void onDestroy1() {
super.onDestroy();
if(ad != null) {
ad.destroyAd();
}
AppTracker.closeSession(getApplicationContext(),true);
}
@SuppressWarnings("unused")
private AdController ad1;
public void onCreate1(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ad = new AdController(this, "ID");
ad.loadAd();
}
public void onDestroy() {
ad.destroyAd();
super.onDestroy();
}
}
If anyone know the problem please let me know
Thanks in advance
PS: Im a Java / android development beginner. Thats my first project. And sorry for my English im from Germany :)
Few things to notice:
onCreate(), you're not initializing your AdControlleronCreate11()andonCreate1()on the other hand, which are never called, as these are not Activity lifecycle methodsonDestroy1(), whatever you're doing there, is never called, because onDestroy1() is NOT Activity lifecycle methodWhat you have to do:
1.You should initialize your AdController in onCreate(), which gets called when Activity is created, so move the code from onCreate11() or onCreate1() to onCreate()
2. Your cleanup code can be in onDestroy(), so move it from onDestroy1() to onDestroy()
3. Make sure your MY_LB_AUDIO_ID, APPFIREWORKS_API_KEY and MY ID are valid strings.
More about activities and lifecycles here, here and here.