Sunday, September 29, 2013

android phonegap developer log

1.add one ad in phonegap in android

FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.WRAP_CONTENT);

params.gravity = Gravity.BOTTOM;

LinearLayout layout = super.root;
layout.addView(new AdView(this, AdSize.BANNER, AdMob_Ad_Unit),params);




see here:PhoneGap-Android-Native-AdMob


2.add one splashscreen in phonegap


when java onCreate

super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html", 10000);

when javascript hide splashscreen:

if(navigator.splashscreen)
navigator.splashscreen.hide();




see here: Splashscreen


3.java startActivity in phonegap

Intent intent = new Intent();
intent.setClassName(packageName, className);
startActivity(intent);

check has app:

public static Boolean hasApp(String packageName, String className) {
Boolean f = false;
try {
if ((null != className) && (className.length() > 0)) {
if (null != PkrssActivity.s_pkrss.getPackageManager().getPackageInfo(packageName, 0))
f = true;
return f;
}

try {
PackageInfo pi = PkrssActivity.s_pkrss.getPackageManager().getPackageInfo(packageName, 0);

Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER);
resolveIntent.setPackage(pi.packageName);

List<ResolveInfo> apps = PkrssActivity.s_pkrss.getPackageManager().queryIntentActivities(resolveIntent, 0);

ResolveInfo ri = apps.iterator().next();
if (ri != null) {
if (ri.activityInfo.name == className)
return true;
}
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {

}
return f;
}

1 comment:

java development company said...

Heya i'm just initially the following. I stumbled upon the following aboard i find It really useful & this solved the problem outside a great deal. I'm hoping to offer anything just as before in addition to support other folks as if you made it easier for me.