AdColony implementierung schwarzer Bildschirm

  • Antworten:1
abg jid
  • Forum-Beiträge: 51

24.10.2015, 13:56:28 via Website

HI,

und zwar versuche ich momentan AdColony in meine app zu implementieren dafür benutze ich folgenden Code

extends Activity implements AdColonyAdAvailabilityListener {

private AdColonyNativeAdView native_ad;
private LinearLayout native_ad_layout;

private int width;
private float density;

private final String APP_ID = "appXXXXXXXXXXX";
private final String ZONE_ID ="XXXXXXXXXXX";

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


    DisplayMetrics display_metrics = getResources().getDisplayMetrics();
    width = display_metrics.widthPixels > display_metrics.heightPixels ? display_metrics.heightPixels : display_metrics.widthPixels;
    density = display_metrics.density;;


    AdColony.configure( this, "version:1.0,store:google", APP_ID, ZONE_ID );
    AdColony.addAdAvailabilityListener( this );

}

@Override
protected void onPause()
{
    super.onPause();
    AdColony.pause();
}

@Override
protected void onResume()
{
    super.onResume();
    AdColony.resume( this );

    //For when Activity is recreated - let's try and add a Instant-Feed ad if available
    if (native_ad == null && AdColony.statusForZone( ZONE_ID ).equals( "active" ) )
    {
        add_native_ad_view( ZONE_ID );
    }
}

@Override
protected void onDestroy()
{
    super.onDestroy();
    if (native_ad != null)
    {
        native_ad.destroy();
        native_ad = null;
    }
}

private boolean add_native_ad_view( String zone_id )
{
    native_ad = new AdColonyNativeAdView( this, zone_id, width, (int)(density*200) );

    //Additionally, you can retrieve/place the following metadata into your layout as desired:
    //native_ad.getAdvertiserName();
    //native_ad.getTitle();
    //native_ad.getDescription();
    //native_ad.getAdvertiserImage();

    if (native_ad.isReady())
    {
        //Make sure UI changes are happening on the main thread
        runOnUiThread( new Runnable()
        {
            @Override
            public void run()
            {
                native_ad_layout.addView( native_ad );
                Toast.makeText( AfghanTVActivity.this,
                                "Instant-Feed ad added to layout. Scroll through your feed to find it.",
                                Toast.LENGTH_LONG).show();
            }
        } );

        return true;
    }

    native_ad = null;
    return false;
}

@Override
public void onAdColonyAdAvailabilityChange( boolean available, String zone_id )
{
    //If the zone now has ads available and we don't currently have an ad in
    //our feed, we'll add one here.
    if (available && native_ad == null)
    {
        add_native_ad_view( zone_id );
    }

    VideoView vidView = (VideoView) findViewById(R.id.videoView1);

    String vidAddress = "http://streaming.ustream.tv/Video/991/streams/live/playlist.m3u8";
    Uri vidUri = Uri.parse(vidAddress);

    vidView.setVideoURI(vidUri);
    vidView.start();

    MediaController vidControl = new MediaController(this);
    vidControl.setAnchorView(vidView);
    vidView.setMediaController(vidControl);
    }
}

Jetzt habe ich das Problem das nichts erscheint der Bildschirm bleibt einfach schwarz.

Ich hoffe jemand kann mir helfen Danke :)

Antworten
Frederik B.
  • Forum-Beiträge: 53

17.11.2015, 22:31:26 via Website

Die App ist doch wirklich einfaches Android und nichts komisches oder?:?

Weil dann versteh ich nicht warum man da so ein Aufwand betreibt? :D

Im Normalfall schreibt man da hin AdCololy... ad = new Adolony...
ad.show(); // und fertig ist der quatsch?

Aber scheint ja auch dein Video zu sein was du da abspielen möchtest,
aber es sieht ziemlich komisch aus. :D

Kann man das nicht einfach starten ohne Thread und View oder der gleichen?(thinking)

Antworten