Upgrade Android Version #1
@@ -1,26 +0,0 @@
 | 
				
			|||||||
package com.hyperling.apps.games;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import android.content.Context;
 | 
					 | 
				
			||||||
import android.support.test.InstrumentationRegistry;
 | 
					 | 
				
			||||||
import android.support.test.runner.AndroidJUnit4;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import org.junit.Test;
 | 
					 | 
				
			||||||
import org.junit.runner.RunWith;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import static org.junit.Assert.*;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Instrumentation test, which will execute on an Android device.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
@RunWith(AndroidJUnit4.class)
 | 
					 | 
				
			||||||
public class ExampleInstrumentedTest {
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
    public void useAppContext() throws Exception {
 | 
					 | 
				
			||||||
        // Context of the app under test.
 | 
					 | 
				
			||||||
        Context appContext = InstrumentationRegistry.getTargetContext();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        assertEquals("apps.hyperling.com.platformer", appContext.getPackageName());
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,36 +0,0 @@
 | 
				
			|||||||
package com.hyperling.apps.games;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import android.content.Context;
 | 
					 | 
				
			||||||
import android.content.SharedPreferences;
 | 
					 | 
				
			||||||
import android.view.View;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import com.google.android.gms.ads.AdRequest;
 | 
					 | 
				
			||||||
import com.google.android.gms.ads.AdView;
 | 
					 | 
				
			||||||
import com.google.android.gms.ads.MobileAds;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Created by ling on 12/26/16.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class AdsHelper {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // To be called in onResume in Activities
 | 
					 | 
				
			||||||
    public static void toggleAds(SharedPreferences sharedPreferences, String adsKey, Context applicationContext, AdView mAdView){
 | 
					 | 
				
			||||||
        // Enable ads?
 | 
					 | 
				
			||||||
        boolean adsEnabled = sharedPreferences.getBoolean(adsKey, false);
 | 
					 | 
				
			||||||
        if (adsEnabled) {
 | 
					 | 
				
			||||||
            mAdView.setVisibility(View.VISIBLE);
 | 
					 | 
				
			||||||
            MobileAds.initialize(applicationContext, "ca-app-pub-3940256099942544~3347511713");
 | 
					 | 
				
			||||||
            AdRequest adRequest = new AdRequest.Builder()
 | 
					 | 
				
			||||||
                    .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
 | 
					 | 
				
			||||||
                    .addTestDevice("C6A494DC6E7C9AC29102694D48487084") // Nexus 7
 | 
					 | 
				
			||||||
                    .addTestDevice("6545BCC9B60A394005546783687339B7") // Moto G
 | 
					 | 
				
			||||||
                    .build();
 | 
					 | 
				
			||||||
            mAdView.loadAd(adRequest);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else{
 | 
					 | 
				
			||||||
            mAdView.setVisibility(View.GONE);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,17 +0,0 @@
 | 
				
			|||||||
package com.hyperling.apps.games;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import org.junit.Test;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import static org.junit.Assert.*;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Example local unit test, which will execute on the development machine (host).
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
public class ExampleUnitTest {
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
    public void addition_isCorrect() throws Exception {
 | 
					 | 
				
			||||||
        assertEquals(4, 2 + 2);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user