Airpush Application information not avaliable - android

I have integrated Airpush Bundle SDK in my new android app following this documentation. The problem is I am not seeing any ad. I have provided the MainActivity.java, AndroidManifest.xml & LogCat below. What is the meaning of the message:
Application information not avaliable
and what do I need to do in order to fix this problem?
MainActivity.java
package mg.mynewandroidapp;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;
import com.oadx.khsz210697.AdListener;
import com.oadx.khsz210697.AdListener.AdType;
import com.oadx.khsz210697.MA;
public class MainActivity extends Activity {
private ListView listView1;
private MA ma;
private AdListener adCallbackListener;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if(ma==null)
ma=new MA(this, adCallbackListener, true);
ma.callSmartWallAd();
ma.call360Ad(this, 0, false, null);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
#Override
public void onBackPressed() {
//Displaying Cached SmartWall Ad
try {
ma.showCachedAd(this, AdType.smartwall);
} catch (Exception e)
{
super.onBackPressed();
}
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mg.mynewandroidapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/ILYSTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
<meta-data android:name="com.oadx.XXXXXXXXXX.APPID" android:value="MY_APP_ID" />
<meta-data android:name="com.oadx.XXXXXXXXXX.APIKEY" android:value="android*MY_API_KEY"/>
<activity android:exported="false" android:name="com.oadx.XXXXXXXXXX.AdActivity"
android:configChanges="orientation|screenSize"
android:theme="#android:style/Theme.Translucent" />
<activity android:name="com.oadx.XXXXXXXXXX.BrowserActivity"
android:configChanges="orientation|screenSize" />
<activity android:name="com.oadx.XXXXXXXXXX.VActivity"
android:configChanges="orientation|screenSize" android:screenOrientation="landscape"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" >
</activity>
<service android:name="com.oadx.XXXXXXXXXX.LService" android:exported="false"></service>
<receiver android:name="com.oadx.XXXXXXXXXX.BootReceiver" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
LogCat
11-21 21:06:50.229: I/BunSDK(11425): Status code: 200
11-21 21:06:50.229: I/BunSDK(11425): 360 Json: {"status":204,"message":"ADS Not Available"}
11-21 21:06:50.829: I/BunSDK(11425): Status code: 200
11-21 21:06:50.829: I/BunSDK(11425): SmartWall JSON: {"status":100,"count":0,"url":"","message":"Application information not avaliable"}

Related

E/com.parse.PushService

Hey every body i have a probleme with PushService i had this message
ClassLoader referenced unknown path: /data/app/com.merrou.GuideApp-1/lib/x86
05-03 22:53:02.879 28956-28956/com.merrou.GuideApp E/com.parse.PushService: The Parse push service cannot start because Parse.initialize has not yet been called. If you call Parse.initialize from an Activity's onCreate, that call should instead be in the Application.onCreate. Be sure your Application class is registered in your AndroidManifest.xml with the android:name property of your tag.
first i search in google and I found it necessary to initialize your name class in application in AndroidManifest but when i initialized i got an com.merrou.GuideApp.MAinActivity is not assignable to com.merrou.GuideApp.Application
Thank you for your help
AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.merrou.GuideApp" >
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:protectionLevel="signature"
android:name="com.merrou.GuideApp.permission.C2D_MESSAGE" />
<uses-permission android:name="com.merrou.GuideApp.permission.C2D_MESSAGE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_logo_app"
android:label="#string/app_name"
android:theme="#style/MyMaterialTheme"
>
<activity
android:name="com.merrou.GuideApp.Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.merrou.GuideApp.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Fragment_TourList"
android:configChanges="orientation|keyboardHidden|screenSize" >
</activity>
<activity
android:name=".Fragment_DetailTour"
android:configChanges="orientation|keyboardHidden|screenSize" >
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
</application>
</manifest>
MainActivity
package com.merrou.GuideApp;
import android.app.Fragment;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import com.parse.Parse;
import com.parse.ParseAnalytics;
import com.parse.ParseInstallation;
import com.parse.PushService;
public class MainActivity extends ActionBarActivity
implements NavigationDrawerCallbacks {
/**
* Fragment managing the behaviors, interactions and presentation of the navigation drawer.
*/
private NavigationDrawerFragment mNavigationDrawerFragment;
private Toolbar mToolbar;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.drawer_activity_main);
mToolbar = (Toolbar) findViewById(R.id.tool_bar);
setSupportActionBar(mToolbar);
//Parse push notification
Parse.initialize(this, getString(R.string.parse_application_id), getString(R.string.parse_client_key));
PushService.setDefaultPushCallback(this, MainActivity.class);
ParseInstallation.getCurrentInstallation().saveInBackground();
ParseAnalytics.trackAppOpened(getIntent());
mNavigationDrawerFragment = (NavigationDrawerFragment)
getFragmentManager().findFragmentById(R.id.fragment_drawer);
// Set up the drawer.
mNavigationDrawerFragment.setup(R.id.fragment_drawer, (DrawerLayout) findViewById(R.id.drawer), mToolbar);
// populate the navigation drawer
mNavigationDrawerFragment.setUserData(getResources().getString(R.string.app_name), getResources().getString(R.string.email), BitmapFactory.decodeResource(getResources(), R.drawable.ic_logo_app));
}
#Override
public void onNavigationDrawerItemSelected(int position) {
Fragment fragment;
switch (position) {
case 0: //stats
fragment = getFragmentManager().findFragmentByTag(Fragment_Guide.TAG);
if (fragment == null) {
fragment = new Fragment_Guide();
}
getFragmentManager().beginTransaction().replace(R.id.container, fragment, Fragment_Guide.TAG).commit();
break;
case 1:
fragment = getFragmentManager().findFragmentByTag(Fragment_Favorite.TAG);
if (fragment == null) {
fragment = new Fragment_Favorite();
}
getFragmentManager().beginTransaction().replace(R.id.container, fragment, Fragment_Favorite.TAG).commit();
break;
case 2:
fragment = getFragmentManager().findFragmentByTag(Fragment_About.TAG);
if (fragment == null) {
fragment = new Fragment_About();
}
getFragmentManager().beginTransaction().replace(R.id.container, fragment, Fragment_About.TAG).commit();
break;
}
}
#Override
public void onBackPressed() {
if (mNavigationDrawerFragment.isDrawerOpen())
mNavigationDrawerFragment.closeDrawer();
else
super.onBackPressed();
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
if (!mNavigationDrawerFragment.isDrawerOpen()) {
// Only show items in the action bar relevant to this screen
// if the drawer is not showing. Otherwise, let the drawer
// decide what to show in the action bar.
getMenuInflater().inflate(R.menu.unused, menu);
return true;
}
return super.onCreateOptionsMenu(menu);
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
return super.onOptionsItemSelected(item);
}
#Override
protected void onPause() {
super.onPause();
}
#Override
protected void onResume() {
super.onResume();
}
#Override
protected void onDestroy() {
super.onDestroy();
}
}

Android Splash screen cannot load another activity

The following is the code for my Android splash screen activity.
When it attempts to load another activity, the application crashes on Android 4.0 and 4.1.
I have no idea what's causing this because when it crashes, it does not log any error.
Has anyone come across anything like this befere?
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import org.bitbucket.infovillafoundation.denko.R;
import org.bitbucket.infovillafoundation.denko.component.DaggerDenkoStationComponent;
import org.bitbucket.infovillafoundation.denko.component.DenkoStationComponent;
import org.bitbucket.infovillafoundation.denko.models.DenkoModel;
import org.bitbucket.infovillafoundation.denko.module.DenkoStationModule;
import org.bitbucket.infovillafoundation.denko.service.DenkoStationService;
import butterknife.ButterKnife;
import butterknife.InjectView;
import retrofit.Callback;
import retrofit.RetrofitError;
import retrofit.client.Response;
public class SplashScreenActivity extends Activity {
#InjectView(R.id.imgLogo)
ImageView logoImage;
#InjectView(R.id.welcomeText)
TextView welcomeText;
private Handler splashHandler = new Handler();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Runnable r = new Runnable() {
#Override
public void run() {
//********************* application is crashing here
Intent mainIntent = new Intent(SplashScreenActivity.this, LanguageOptionActivity.class);
startActivity(mainIntent);
finish();
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
}
};
setContentView(R.layout.activity_splash);
ButterKnife.inject(this);
DenkoStationComponent component = DaggerDenkoStationComponent.builder().denkoStationModule(new DenkoStationModule()).build();
final DenkoStationService denkoStationService = component.provideDenkoStationService();
Callback<DenkoModel> callback = new Callback<DenkoModel>() {
#Override
public void success(DenkoModel denkoModel, Response response) {
toast(R.string.server_connection_successful);
denkoStationService.updateDatabaseWithDenkoModel(denkoModel);
}
#Override
public void failure(RetrofitError error) {
toast(R.string.server_connection_failed);
}
public void toast(int textId) {
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.toast_layout,
(ViewGroup) findViewById(R.id.toast_layout_root));
TextView text = (TextView) layout.findViewById(R.id.toast_text);
text.setText(getResources().getString(textId));
Toast toast = new Toast(getApplicationContext());
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
}
};
denkoStationService.fetchDenkoModel(denkoStationService.fetchDenkoLastDataState(), callback);
if (isNetworkAvailable())
splashHandler.postDelayed(r, 3000);
else {
toast(R.string.no_internet_connection);
splashHandler.postDelayed(r, 3000);
}
//********************* application is crashing here
Intent mainIntent = new Intent(this, LanguageOptionActivity.class);
startActivity(mainIntent);
}
#Override
protected void onResume() {
super.onResume();
}
private boolean isNetworkAvailable() {
ConnectivityManager connectivityManager
= (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null;
}
private void toast(int textId) {
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.toast_layout,
(ViewGroup) findViewById(R.id.toast_layout_root));
TextView text = (TextView) layout.findViewById(R.id.toast_text);
text.setText(getResources().getString(textId));
Toast toast = new Toast(getApplicationContext());
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
}
}
Edit: AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.bitbucket.infovillafoundation.denko">
<uses-sdk android:minSdkVersion="14" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<permission
android:name="org.bitbucket.infovillafoundation.denko.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="org.bitbucket.infovillafoundation.denko.MAPS_RECEIVE" />
<application
android:name=".application.DenkoApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name=".activity.SplashScreenActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activity.MainActivity"
android:label="#string/title_activity_home"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.NoTitleBar" />
<activity
android:name=".activity.LanguageOptionActivity"
android:label="#string/title_activity_language_option"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.NoTitleBar" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyAubZsgoC4Z64qcOSpfK4grjrK5zrTEWxk" />
</application>
</manifest>
I think that since the crashes do not occur with a higher Android version, the problem might be resulting from an incompatible OpenGL version.
You can use following Activity with some simple content. Inject the layout (see below) and register in the layout file an onclick-listener (method "forward"). In this method you can call your next activity:
public class SplashScreen extends Activity{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splashscreen);
}
public void forward(View v){
startActivity(new Intent(this, MainActivity.class), 0);
}
}
splashscreen.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ImageView
android:id="#+id/splashscreen"
android:onClick="forward"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#drawable/ic_launcher" />
</LinearLayout>
Add in your AndroidManifest.xml:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen" >
<activity
android:name=".SplashScreen"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" />
</application>
The class "MainActivity" represents your main activity and the class "SplashScreen" represents a simple splash screen.
I hope this will help you:)
The problem i see is that while calling the activity tag you still use .activity in the name attribute
i.e you used android:name=".activity.MainActivity"
instead of android:name=".MainActivity" both for splash screen activity and main activity.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.bitbucket.infovillafoundation.denko">
<uses-sdk android:minSdkVersion="14" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<permission
android:name="org.bitbucket.infovillafoundation.denko.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="org.bitbucket.infovillafoundation.denko.MAPS_RECEIVE" />
<application
android:name=".application.DenkoApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name=".SplashScreenActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/title_activity_home"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.NoTitleBar" />
<activity
android:name=".activity.LanguageOptionActivity"
android:label="#string/title_activity_language_option"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.NoTitleBar" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyAubZsgoC4Z64qcOSpfK4grjrK5zrTEWxk" />
</application>
</manifest>
I think you cannot added your splash screen in AndroidManifest.xml.plz check
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class Splash extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Thread logoTimer = new Thread() {
public void run() {
try {
int logoTimer = 0;
while (logoTimer < 500) {
sleep(100);
logoTimer = logoTimer + 100;
}
Intent newIntent = new Intent(Splash.this, MainActivity.class);
startActivity(newIntent);
} catch(InterruptedException e) {
e.printStackTrace();
} finally {
finish();
}
}
};
logoTimer.start();
}
}
in Android Manifest.xml
<activity
android:name=".Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Device stops receiving notifications after 24 hours

I have an application in android and phonegap and I'm using Parse to send pushs.
Everything works fine when I install it: I can send and receive notifications.
After 5 hours, it starts to delay the pushs and after one day, it stops and I cant receive it anymore.
I see the notifications in dashboard but not in device.
Can someone give me a sugestion ?
Manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.meeto1"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<application
android:name="com.example.meeto1.ParseApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.meeto1.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.parse.PushService" />
<receiver android:name="com.example.meeto1.PushReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.ParseBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<meta-data android:name="com.parse.push.notification_icon"
android:resource="#drawable/ic_launcher"/>
</application>
</manifest>
PushReceiver.java:
package com.example.meeto1;
import org.json.JSONException;
import org.json.JSONObject;
import com.parse.ParsePushBroadcastReceiver;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
public class PushReceiver extends ParsePushBroadcastReceiver {
#Override
public void onPushOpen(Context context, Intent intent) {
Log.e("Push", "Clicked2");
Bundle extras = intent.getExtras();
String message = extras != null ? extras.getString("com.parse.Data") : "";
JSONObject jObject;
try {
jObject = new JSONObject(message);
for (int i=0; i < 10; i++)
{
Toast toast = Toast.makeText(context, jObject.getString("alert"), Toast.LENGTH_LONG);
toast.show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
#Override
protected Class<? extends Activity> getActivity(Context context, Intent intent) {
Log.v("Parse", "getActivity called");
return super.getActivity(context, intent);
}
#Override
protected void onPushReceive(Context context, Intent intent) {
Log.v("Parse", "onPushReceive called");
super.onPushReceive(context, intent);
}
#Override
public void onReceive(Context context, Intent intent) {
Log.v("Parse", "onReceive Called");
super.onReceive(context, intent);
}
}
MainActivity.java:
package com.example.meeto1;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import org.apache.cordova.DroidGap;
import android.content.Context;
import android.location.Address;
import android.location.Geocoder;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
import com.parse.Parse;
import com.parse.ParseAnalytics;
import com.parse.ParseInstallation;
import com.parse.ParsePush;
public class MainActivity extends DroidGap {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
this.appView.addJavascriptInterface(new MainActivity(), "Android");
this.appView.addJavascriptInterface(new MeusMetodos(), "MeusMetodos");
this.appView.getSettings().setJavaScriptEnabled(true);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
#Override
public void onStop() {
Log.w(TAG, "App stopped");
super.onStop();
}
#Override
public void onDestroy() {
Log.w(TAG, "App destoryed");
super.onDestroy();
}
}
ParseApplication.java
package com.example.meeto1;
import com.parse.Parse;
import com.parse.ParseInstallation;
import com.parse.ParsePush;
import com.parse.PushService;
import android.app.Application;
public class ParseApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
Parse.initialize(this, "xxx", "xxx");
ParsePush.subscribeInBackground("todosUsuarios");
ParseInstallation.getCurrentInstallation().saveInBackground();
}
}
Just to let you know I solved it.
In my Manifest,inside <application>, I'm using the GCM Parse support and my notifications are working now:
<receiver android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.example.meeto1" />
</intent-filter>

how to mopub ads add in application

i want to add ads banner in my application i have integrate mopub sdk with my project and import and add library to the my project now my question is how to add banner disply and where code i have to write in my application java code and xml code about ads so please help enyone
my java code and mainifest file code is given below
mainactivity.java
package com.example.ration;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.os.Build;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
public class MainActivity extends Activity {
private WebView web;
int k;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
web=(WebView)findViewById(R.id.web);
web.getSettings().setJavaScriptEnabled(true);
web.setWebViewClient(new WebViewClient());
web.getSettings().setBuiltInZoomControls(true);
web.loadUrl("http://dcs-dof.gujarat.gov.in/live-info.htm");
// web.getProgress();
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0,1,menu.NONE,"About");
menu.add(0,2,menu.NONE,"Feedback");
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
int id=item.getItemId();
if(id == 1)
{
Toast.makeText(MainActivity.this,"About",Toast.LENGTH_LONG).show();
Intent i=new Intent(MainActivity.this,about.class);
startActivity(i);
}
else {
Toast.makeText(MainActivity.this,"Feedback",Toast.LENGTH_LONG).show();
Intent i2 =new Intent(MainActivity.this,feedback.class);
startActivity(i2);
}
return super.onOptionsItemSelected(item);
}
private boolean doubleBackToExitPressedOnce = false;
#Override
protected void onResume() {
super.onResume();
// .... other stuff in my onResume ....
this.doubleBackToExitPressedOnce = false;
}
#Override
public void onBackPressed() {
if (doubleBackToExitPressedOnce) {
super.onBackPressed();
return;
}
this.doubleBackToExitPressedOnce = true;
Toast.makeText(this,"Press Again to Exit", Toast.LENGTH_SHORT).show();
}
}
and my manifest file is
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ration"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.ration.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.example.ration.about"></activity>
<activity android:name="com.example.ration.feedback"></activity>
<activity android:name="com.mopub.mobileads.MoPubActivity" android:configChanges="keyboardHidden|orientation"/>
<activity android:name="com.mopub.mobileads.MraidActivity" android:configChanges="keyboardHidden|orientation"/>
<activity android:name="com.mopub.mobileads.MraidBrowser" android:configChanges="keyboardHidden|orientation"/>
<activity android:name="com.mopub.mobileads.MraidVideoPlayerActivity" android:configChanges="keyboardHidden|orientation"/>
<activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<activity android:name="com.millennialmedia.android.MMActivity" android:theme="#android:style/Theme.Translucent.NoTitleBar" android:configChanges="keyboardHidden|orientation|keyboard" />
<activity android:name="com.millennialmedia.android.VideoPlayer" android:configChanges="keyboardHidden|orientation|keyboard" />
</application>
</manifest>
I think you should better go through the guide for Mopub Banner Ads Integration which explains you the steps of banner ads integration.
Hope this will help you.
Use view in XML file
<com.mopub.mobileads.MoPubView
android:id="#+id/mrect_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_weight="1" />
in activity Load code
pass id of view in below function ,unit id of ur app,and keywords of cataogry of ads
public void loadMoPubView(MoPubView moPubView, String adUnitId, String keywords) {
if (moPubView == null) {
Utils.logToast(LockScreenActivity.this, "Unable to inflate MoPubView from xml.");
//Toast.makeText(this, "Unable to inflate MoPubView from xml.", Toast.LENGTH_SHORT).show();
return;
}
try {
Utils.validateAdUnitId(adUnitId);
} catch (IllegalArgumentException exception) {
Utils.logToast(LockScreenActivity.this, exception.getMessage());
return;
}
moPubView.setBannerAdListener(this);
moPubView.setAdUnitId(adUnitId);
moPubView.setKeywords(keywords);
moPubView.setAutorefreshEnabled(true);
moPubView.loadAd();
}

Open app on number of clicks of power button using broadcast receiver

I am trying to generate some log and put up a toast on screen after power button click.
But it doesn't seem to work. Here's the code:
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.pbtest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.ACTION_SHUTDOWN" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.test.pbtest.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="com.test.pbtest.MyReceiver">
<intent-filter>
<action android:name="android.intent.action.SCREEN_OFF"></action>
<action android:name="android.intent.action.SCREEN_ON"></action>
<action android:name="android.intent.action.ACTION_POWER_CONNECTED"></action>
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED"></action>
<action android:name="android.intent.action.ACTION_SHUTDOWN"></action>
</intent-filter>
</receiver>
</application>
</manifest>
MyReceiver.java class:
package com.test.pbtest;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;
public class MyReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context arg0, Intent arg1) {
// TODO Auto-generated method stub
Log.v("Hurray!", "Power button was clicked!");
Toast.makeText(arg0, "power button clicked",Toast.LENGTH_LONG).show();
}
}
MainActivity.java class:
package com.test.pbtest;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
As per my knowledge, i need not register my receiver explicitly as i have used it in manifest file. Please guide me where i am going wrong.
you will need to add ACTION_SHUTDOWN permission in AndroidManifest.xml :
<uses-permission android:name="android.permission.ACTION_SHUTDOWN" />
for some reason you have to register your receiver on runtime.. you can register it via service

Categories

Resources