Android addmob app force closed - android

I am working with android app, and I am trying to add the google addmob to my app. And there are no errors in my code but the app seems to be force closed while running. I cant find the error. Please help me,
I used the code -
adView = new AdView(this, AdSize.BANNER, "my add id");
RelativeLayout layout = (RelativeLayout)findViewById(R.id.adView);
layout.addView(adView);
AdRequest request = new AdRequest();
request.setTesting(false);
adView.loadAd(request);
please help me since i am new to android development
Logcat:
11-09 17:26:43.508: E/AndroidRuntime(8982): at android.app.Activity.setContentView(Activity.java:1862)
11-09 17:26:43.508: E/AndroidRuntime(8982): Caused by: java.lang.ClassNotFoundException: com.google.ads.AdView

// try this
1. download latest google-play-services,jar
2. add jar to project build path
**main.xml**
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/lnrMain">
</LinearLayout>
public class MyActivity extends FragmentActivity {
LinearLayout lnrMain;
#Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
lnrMain = (LinearLayout) findViewById(R.id.lnrMain);
runOnUiThread(new Runnable() {
#Override
public void run() {
AdView adView = new AdView(MyActivity.this);
adView.setAdUnitId("0445b7141d9d4e1b");
adView.setAdSize(AdSize.BANNER);
AdRequest.Builder builder = new AdRequest.Builder();
builder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
adView.loadAd(builder.build());
lnrMain.addView(adView);
}
});
}
}
**AndroidManifest.xml**
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.Demo"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8"
android:targetSdkVersion="17"/>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:label="#string/app_name"
android:icon="#drawable/ic_launcher">
<activity
android:name="MyActivity"
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.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<meta-data
android:name="ADMOB_ALLOW_LOCATION_FOR_ADS"
android:value="true" />
<meta-data
android:name="com.google.android.gms.version"
android:value="4030500" />
</application>
</manifest>

Yesterday I had my first app integrated with admob and what I did is just I added a .jar Library to Java Build Path,. When in Manifest file I added these lines above closing application tag:
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
and these permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
This is how my Manifest.xml looks like:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="PACKAGENAME"
android:versionCode="1"
android:versionName="1.1" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>
</manifest>
When in my main_acitivty.xml I added these lines of code where I actually want to see my Ad Banner:
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="YOU-ID"
ads:loadAdOnCreate="true" >
</com.google.ads.AdView>
I actually did not write any code in my .java file. Because you can choose whetever to implement AdMob via XML or programatically.
All these steps are provided in here -> AdMob Banners

here is my code am used
****MainActivity.java`
package com.example.smacon;
import com.google.ads.*;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.Surface;
import android.webkit.WebView;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
public class MainActivity extends Activity {
private AdView adView;
private WebView webView;
public void onCreate(Bundle savedInstanceState) {
final Context context = this;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AdRequest adRequest = new AdRequest();
//test mode on EMULATOR
adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
//test mode on DEVICE (this example code must be replaced with your device uniquq ID)
adRequest.addTestDevice("4G74FC73D62D42B62A7F7DA61EF5F776");
adView = (AdView)findViewById(R.id.adView);
// Initiate a request to load an ad in test mode.
// You can keep this even when you release your app on the market, because
// only emulators and your test device will get test ads. The user will receive real ads.
adView.loadAd(adRequest);
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("my url");
webView.setWebViewClient(new MyWebViewClient());
}
#Override
public void onDestroy() {
if (adView != null) {
adView.destroy();
}
super.onDestroy();
}
}
***** MyWebViewClient.java
package com.example.smacon;
import android.graphics.Bitmap;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MyWebViewClient extends WebViewClient {
// show the web page in webview but not in web browser
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
#Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
// webProg.setVisibility(View.GONE);
}
#Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
#Override
public void onLoadResource(WebView view, String url) {
super.onLoadResource(view, url);
}
}
**** manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.smacon"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:debuggable="true"
android:icon="#drawable/logo"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.smacon.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.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode
|screenSize|smallestScreenSize" >
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
****activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/webView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<com.google.ads.AdView android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="7565756565"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"/>
</LinearLayout>
no errors in this code. But it is forced closed . :(

Related

Android banner not working

When I run it it gives a java heap space error and again it give message "your project contain errors please fix them before running" and again message display related to "an internal error occured please close workbench". I also use the test id of mobile but same error occurs each time.
Layout file:
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<com.google.android.gms.ads.AdView`enter code here`
android:id="#+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize=" SMART_BANNER "
ads:adUnitId="ca-app-pub-7222219345251053/8664557124" />
</LinearLayout>
newadmobtutorialmanifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidbegin.newadmobtutorial"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<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" />
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>
</manifest>
mainActivity.java
package com.androidbegin.newadmobtutorial;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.InterstitialAd;
import android.os.Bundle;
import android.app.Activity;
public class MainActivity extends Activity {
private InterstitialAd interstitial;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the view from activity_main.xml
setContentView(R.layout.activity_main);
// Prepare the Interstitial Ad
interstitial = new InterstitialAd(MainActivity.this);
// Insert the Ad Unit ID
interstitial.setAdUnitId("ca-app-pub-7222219345251053/8664557124");
//Locate the Banner Ad in activity_main.xml
AdView adView = (AdView) this.findViewById(R.id.adView);
// Request for Ads
AdRequest adRequest = new AdRequest.Builder()
// Add a test device to show Test Ads
// .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
// .addTestDevice("EB81B984CF6F807FED26757A39F8FF")
.build();
// Load ads into Banner Ads
adView.loadAd(adRequest);
// Load ads into Interstitial Ads
interstitial.loadAd(adRequest);
// Prepare an Interstitial Ad Listener
interstitial.setAdListener(new AdListener() {
public void onAdLoaded() {
// Call displayInterstitial() function
displayInterstitial();
}
});
}
public void displayInterstitial() {
// If Ads are loaded, show Interstitial else show nothing.
if (interstitial.isLoaded()) {
interstitial.show();
}
}
}
and this is my eclipse.ini
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.200.v20120913-144807
-product
com.android.ide.eclipse.adt.package.adtproduct
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
512m
--launcher.defaultAction
openFile
-vmargs “c:\Program Files\Java\jdk1.7.0_07\bin\javaw.exe”
-Dosgi.requiredJavaVersion=1.7
-XX:MaxPermSize=2028m
-XX:CompileThreshold=5
-XX:MaxGCPauseMillis=10
-XX:MaxHeapFreeRatio=70
-Xms2028m
-Xmx6120m
Try to set adUnitId from dynamicly, e.g.
<uradreference>.setAdUnitId("ca-app-pub-7409237681170791/6275305467");
also try with ads:adSize="BANNER" first! It should work.

admob does not show up in android

I'm a beginner,I'm trying to set an admob add in my app.But I have some errors witch I can't manage.
XmlFile
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<com.google.ads.AdView android:id="#+id/main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="MY_AD_UNIT_ID"
ads:adSize="BANNER"
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
ads:loadAdOnCreate="true"/>
</RelativeLayout>
Manifest File.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.admob"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />
<application
android:allowBackup="true" android:icon="#drawable/ic_launcher" android:label="#string/app_name" android:theme="#style/AppTheme" >
<activity
android:name="com.example.admob.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.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|scre enSize|smallestScreenSize" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>
Java Code:
package com.example.admob;
import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
public class MainActivity extends Activity
{
private static final String MY_AD_UNIT_ID = null;
private AdView adView;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
adView = new AdView(this, AdSize.BANNER, MY_AD_UNIT_ID);
RelativeLayout main = (RelativeLayout)findViewById(R.id.main);
main.addView(adView);
adView.loadAd(new AdRequest());
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
adRequest.addTestDevice("TEST_DEVICE_ID");
}
#Override
public void onDestroy() {
adView.destroy();
super.onDestroy();
}
}
when Activity start this type error occur onFailedToReceivedAd(InvalidAdRequest).
I don't know what is the problem.
You are not loading the AdRequest which has the test devices registered. Change your code to:
//....
main.addView(adView);
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
adRequest.addTestDevice("TEST_DEVICE_ID");
adView.loadAd(adRequest);
In your relativelayout that contains the adview, are you appending the content layout after the adview. If so, what are the android:layout_width and android:layout_height values. If you are using fill_parent/match_parent for both, then your adview will never show.
The trick is to change the relativelayout to the linearlayout. Then for the content layout within this linearlayout, set its android:layout_width="fill_parent" and android:layout_height="0dp". Add a new attribute android:layout_weight="1" for the content layout. What these does is to ask the content layout to accomodate the remaining space of linearlayout after the adview has occupied its place. Hope this helps.

change White background during app launch

I want to get rid of the white color during the short period when my app is launching but the content isn't displayed, yet.
My main activity is :-
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.kam"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.kam.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>
</application>
</manifest>
how can replace white background to progress bar ?
Update :-
mainfest.xml :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.kam"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.kam.StartPoint"
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.kam.MainActivity"/>
</application>
</manifest>
splash.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/loading" />
<ProgressBar
android:id="#+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.67" />
</LinearLayout>
startpoint.class
public class StartPoint extends Activity{
ProgressBar progressBar;
private int progressBarStatus = 0;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
progressBar = (ProgressBar)findViewById(R.id.progressBar1);
Thread timer = new Thread(){
public void run(){
try{
sleep(5000);
while(progressBarStatus < 5000){
StartPoint.this.runOnUiThread(new Runnable(){
public void run()
{
progressBar.setProgress(progressBarStatus);
progressBarStatus += 1000;
}
});
}
}catch(InterruptedException e){
e.printStackTrace();
}finally{
Intent openMainList = new Intent(StartPoint.this, com.example.kam.MainActivity.class);
startActivity(openMainList);
}
}
};
timer.start();
}
protected void onPause(){
super.onPause();
finish();
}
}
i will try but when open loading image and open main layout its show error
There a many tutorials and videos for creating Splash Screens, which should give you the desired results.
The basic steps are;
Create a splash image in the desired drawables folders.
Create a theme with your image in it
create an activity using the theme, and have that activity start your current main activity

Android Splash Screen broken

i made a splash screen with this youtube video turtorial here ~> http://www.youtube.com/watch?v=IHg_0HJ5iQo
i saved my files and made sure they are there now when i send it to my device the splash screen does not show up.. i dont know why.
heres my activity_main.xml code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:background="#drawable/back_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
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" >
</RelativeLayout>
here is my splash.xml code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#drawable/splash_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
heres my manafest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.idoser"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.idoser.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>
</application>
</manifest>
So after talking in chat, I see that the reason your splash screen isn't showing up is because you're not doing anything with the splash.xml layout file. If you don't inflate your splash layout or set it as a content view, then you'll never see it.
There are several ways to do this but this is the approach that I would take:
Create a SplashActivity
Make SplashActivity your launcher Activity.
Use a timer to start your main activity.
SplashActivity.java
package com.example.idoser;
import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
public class SplashActivity extends Activity {
AsyncTask<Object, Object, Object> mTimerTask;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
}
#Override
protected void onResume() {
super.onResume();
if(mTimerTask != null) {
mTimerTask.cancel(false);
mTimerTask = null;
}
mTimerTask = new AsyncTask<Object, Object, Object>() {
#Override
protected Object doInBackground(Object... params) {
try {
Thread.sleep(3000); /* 3 second splash screen */
} catch(Exception e) { }
return null;
}
#Override
protected void onPostExecute(Object result) {
super.onPostExecute(result);
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
};
}
#Override
protected void onPause() {
super.onPause();
if(mTimerTask != null) {
mTimerTask.cancel(false);
mTimerTask = null;
}
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.idoser"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.idoser.SplashActivity"
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.idoser.MainActivity"
android:label="#string/app_name" >
</activity>
</application>
</manifest>
Mind you this is not the best possible way to do this but it should at least get your splash screen showing and give you an idea of the direction you need to go.

Android WebView Screen Goes black during load the next or same page

We made an android application for samsung galaxy tab using webview but when we hit the same page or a different page in between we got a black screen for 4-5 seconds after that screen shows the page.
So please tell me what we do for this i don't want that black screen.
Kindly find the below code for the same.
CallKiosk.java
package one97.kiosk;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class CallKiosk extends Activity {
public final String url = "http://10.0.8.178:8088/Kiosk/";
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView webview = new WebView(this);
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new WebViewClient());
setContentView(webview);
webview.loadUrl(url);
}
private class MyWebViewClient extends WebViewClient {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
}
}
Main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<WebView
android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/hello"
/>
</LinearLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="one97.kiosk"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk android:minSdkVersion="8" />
<application android:icon="#drawable/logo" android:label="#string/app_name">
<activity android:name=".CallKiosk"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Try this if useful, webvieew.setBackgroundColor("#FFFFFF")

Categories

Resources