repositories { jcenter() } dependencies { //other dependencies... compile 'com.nolesh.ads:adnolesh-sdk:1.0' }
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="your.p4ck4ge.name" xmlns:tools="http://schemas.android.com/tools"> <!-- YOUR PERMISSIONS --> ... <!-- REMOVE THE OPTIONAL PERMISSION FROM THE MERGED MANIFEST FILE --> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" tools:node="remove" /> ...
<manifest> <application> <meta-data android:name="com.nolesh.ads.API_TOKEN" android:value="YOUR_API_TOKEN" /> </application> </manifest>
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- OPTIONAL PERMISSION --> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- AdNolesh SDK --> <activity android:name="com.nolesh.ads.AdNoleshActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" /> <receiver android:name="com.nolesh.ads.Notification"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED"> </intent-filter> </receiver> <receiver android:name="com.nolesh.ads.AppInstallTrackingReceiver" android:enabled="true" android:exported="true" android:permission="android.permission.INSTALL_PACKAGES"> <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER"> </intent-filter> </receiver> <service android:name="com.nolesh.ads.AppInstallTrackingService" android:enabled="true"/> <service android:name="com.nolesh.ads.AppInstallTrackingJobService" android:permission="android.permission.BIND_JOB_SERVICE"/>
-keep class com.nolesh.ads.** { *; } -dontwarn com.nolesh.ads.**
import com.nolesh.ads.AdNoleshSDK; import com.nolesh.ads.InitSDKEvents; public class YourMainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //1st parameter - Current activity //2nd parameter - Debug mode. Set to true while developing your app AdNoleshSDK.initialize(this, true); //Or you can use overloaded method with 3 parameters //3rd parameter - Callbacks that return the result of initialization AdNoleshSDK.initialize(this, true, new InitSDKEvents() { @Override public void onSuccess() { //SUCCESS } @Override public void onError(String errorMsg) { //FAIL } }); } }
import com.nolesh.ads.IInstallReferrerReceiver; import com.google.analytics.tracking.android.CampaignTrackingReceiver; ... public class YourMainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ... // Receives an INSTALL_REFERRER intent and pass it to other receivers, // including the Google Analytics receiver. AdNoleshSDK.interceptInstallReferrerIntent(new IInstallReferrerReceiver() { @Override public void onReceive(Context context, Intent intent) { // Pass the intent to the Google Analytics receiver and/or other receivers. new CampaignTrackingReceiver().onReceive(context, intent); } }); } }
import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import com.nolesh.ads.AppInstallTrackingReceiver; import com.google.analytics.tracking.android.CampaignTrackingReceiver; /* * A simple Broadcast Receiver to receive an INSTALL_REFERRER * intent and pass it to other receivers, including * the AdNolesh & Google Analytics receivers. */ public class CustomReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { // Pass the intent to other receivers. // Pass the intent to the AdNolesh receiver. new AppInstallTrackingReceiver().onReceive(context, intent); // When you're done, pass the intent to the Google Analytics receiver. new CampaignTrackingReceiver().onReceive(context, intent); } }
<manifest> <application> <!-- Remove the default receiver from the merged manifest file --> <receiver android:name="com.nolesh.ads.AppInstallTrackingReceiver" tools:node="remove" /> <!-- Register your newly created CustomReceiver --> <receiver android:name=".CustomReceiver" android:enabled="true" android:exported="true" android:permission="android.permission.INSTALL_PACKAGES"> <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER"> </intent-filter> </receiver> </application> </manifest>
//1st parameter - the value of the hour when the notification should be displayed //(might be any value from 0-23) //2nd parameter - the value of the minute when the notification should be displayed //(might be any value from 0-59) //3rd parameter - delay represented in days //4th parameter - interval (once, twice a day, etc) //5th parameter - determines whether the current notification schedule will be removed and replaced by this one //6th parameter - small icon which is used in status bar (may be omitted) AdNoleshSDK.setNotification(15, 25, 0, NotificationScheduler.INTERVAL_ONCE, false, R.drawable.ic_statusbar);
AdNoleshSDK.cancelNotification();
//Set the title of the notification ad unit NotificationScheduler.setTitle(this, "Your title"); //Set the content text of the notification ad unit NotificationScheduler.setContentText(this, "Your text");
AdNoleshSDK.setNotification(15, 25, 0, NotificationScheduler.INTERVAL_ONCE, false);
//show offerwall with default title AdNoleshSDK.showOfferwall(); //OR //show offerwall with custom title AdNoleshSDK.showOfferwall("POPULAR APPS"); //OR //shows offerwall with custom title and executes certain logic after it is closed AdNoleshSDK.showOfferwall("POPULAR APPS", new Runnable() { @Override public void run() { //your code } });
//get ListView instance ListView lv = (ListView)view.findViewById(R.id.offerwallListView); AdNoleshSDK.showOfferwall(lv);
ListView myListView = (ListView)view.findViewById(R.id.myListView); MyAdapter myAdapter = new MyAdapter(this, R.layout.my_listview_item, items); OfferwallAdapter newAdapter = OfferwallAdapter.wrapListAdapter(this, myAdapter, myListView); myListView.setAdapter(newAdapter);
listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { position = newAdapter.getItemPosition(position); //OPTION #1 int originalPosition = newAdapter.getItemPosition(position); Object object = newAdapter.getUserItem(originalPosition); //OPTION #2 Object object = adapter.getItemAtPosition(position); //OR Object object = newAdapter.getItem(position); //If the user clicks on the ad unit, then the object is null. //In this case, we have to ignore this action if(object==null) return; //For example Item item = (Item)object; Toast.makeText(getContext(), item.getTitle(), Toast.LENGTH_LONG).show(); } });
//1st parameter - activity AdNoleshSDK.embedHiddenOfferwall(this); //OR //1st parameter - activity //2nd parameter - if true, the handle aligns along the right side AdNoleshSDK.embedHiddenOfferwall(this, false); //OR //1st parameter - activity //2nd parameter - if true, the handle aligns along the right side //3rd parameter - title of the offerwall AdNoleshSDK.embedHiddenOfferwall(this, true, "POPULAR APPS");
//immediate opening hidden offerwall if it's closed //1st parameter - if true, the hidden offerwall will be opened. Otherwise, it will be closed //2nd parameter - apply the animation when the offerwall is opening/closing AdNoleshSDK.hiddenOfferwallSetState(true, false);
OfferwallAdapter.customizeAdUnits(R.layout.your_ad_list, R.id.icon, R.id.title, R.id.description);
//color format: #rrggbb OfferwallAdapter.setBackgroundColor("#cccccc");
//color format: #rrggbb OfferwallAdapter.setTitleColor("#ff9900");
//color format: #rrggbb OfferwallAdapter.setDescriptionColor("#77ccff");
//1st parameter - top color (format: #rrggbb) //2nd parameter - bottom color (format: #rrggbb) OfferwallAdapter.setHeaderBackgroundColor("#3F51B5", "#303F9F");
//color format: #rrggbb OfferwallAdapter.setHeaderTitleColor("#FFFFFF");
//color format: #rrggbb OfferwallAdapter.setHeaderCloseButtonColor("#FF7722");
//1st parameter - color of the handle (format: #rrggbb) //2nd parameter - color of the arrow (format: #rrggbb) OfferwallAdapter.setHandleColor("#3F51B5", "#FFFFFF");
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:adnolesh="http://adnolesh.com"> ... <!-- Set the "persistent" attribute to "true" for permanent banner display --> <com.nolesh.ads.AdNoleshBanner android:id="@+id/banner" android:layout_width="match_parent" android:layout_height="wrap_content" adnolesh:persistent="false"/> ... </RelativeLayout>
import com.nolesh.ads.AdNoleshBanner; ... public void createBanner(ViewGroup parent) { // Set the second parameter to "true" for permanent banner display AdNoleshBanner banner = new AdNoleshBanner(getContext(), false); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); parent.addView(banner, params); } //invoke the function above somewhere you want, for example: button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { RelativeLayout rl = (RelativeLayout)view.findViewById(R.id.bannerContainer); createBanner(rl); } });
<?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:adnolesh="http://adnolesh.com"> ... <!-- Includes AdNolesh banner in preferences --> <!-- Set the "persistent" attribute to "true" for permanent banner display --> <com.nolesh.ads.AdNoleshBannerPreference adnolesh:persistent="false"/> ... </PreferenceScreen>
public class WallpaperSettings extends PreferenceActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.prefs); //Initialize the SDK. //If done earlier in another activity, the SDK doesn't need to be initialized again. AdNoleshSDK.initialize(this, "YOUR_API_TOKEN", true); } }
//enable interstitial ad units in your app AdNoleshSDK.enableInterstitials(true);
//shows full screen interstitial advertisement AdNoleshSDK.showInterstitial(); //OR //shows full screen interstitial advertisement //and executes certain logic after it is closed AdNoleshSDK.showInterstitial(new Runnable() { @Override public void run() { //your code } });
//download a video file //if 'isPersistentVideoRequestMode' is true, this method should be omitted AdNoleshSDK.requestVideo(); //show the video when the user clicks on the button Button button = (Button) view.findViewById(R.id.offerwall); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //if the video is not ready, it won't be shown boolean result = AdNoleshSDK.showVideo(); } });
import com.nolesh.ads.VideoStatusEvents; ... //register a callback that will be called when a video is downloaded, fail, or interrupted //if 'isPersistentVideoRequestMode' is true, the 'onDownloaded' callback will NOT be triggered AdNoleshSDK.requestVideo(new VideoStatusEvents() { @Override public void onDownloaded() { //You need to call Toast.makeText() (and most other functions dealing with the UI) from the UI thread: MainActivity.this.getActivity().runOnUiThread(new Runnable() { public void run() { Toast.makeText(getContext(), "Downloading of the video is completed!", Toast.LENGTH_LONG).show(); } }); AdNoleshSDK.showVideo(); } @Override public void onFail(String errorMsg) {} @Override public void onInterrupted() {} });
//shows full screen video-interstitial advertisement and executes certain logic after it is closed AdNoleshSDK.showVideo(new Runnable() { @Override public void run() { //your code } });
//If enabled, a new video will be requested each time after watching a previous one. //It starts downloading videos immediately after initializing the SDK AdNoleshSDK.setPersistentVideoRequestMode(true);
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:adnolesh="http://adnolesh.com" android:layout_width="match_parent" android:layout_height="match_parent"> ... <!-- Set the "persistent" attribute to "true" for permanent banner display --> <com.nolesh.ads.AdNoleshBanner android:id="@+id/banner" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" adnolesh:persistent="false"/> ... </RelativeLayout>
// Set the second parameter to "true" for permanent banner display AdNoleshBanner banner = new AdNoleshBanner(getContext(), false); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); parent.addView(banner, params);
<?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:adnolesh="http://adnolesh.com"> ... <!-- Includes AdNolesh banner in preferences --> <!-- Set the "persistent" attribute to "true" for permanent banner display --> <com.nolesh.ads.AdNoleshBannerPreference adnolesh:persistent="false" /> ... </PreferenceScreen>
ListView myListView = (ListView)view.findViewById(R.id.myListView); MyAdapter myAdapter = new MyAdapter(getContext(), R.layout.my_listview_item, items); OfferwallAdapter newAdapter = OfferwallAdapter.wrapListAdapter(getContext(), myAdapter, myListView); myListView.setAdapter(newAdapter);