something wrong with my webview of android - java

I am using: windows7, eclipse, sdk up-to-date, avd from android 2.3.3 & milestone <-the NVPACK - in fact
the problem is discussed everywhere, but the solutions did not work for me.
When I try to load a url, it turns out a blank white page
some was saying about htmls, but no ,mine is http://www.google.com or http://www.baidu.com or file:///android_asset/demo.html etc.
and the most carried out solutions
the permission:
<uses-permission android:name="android.permission.INTERNET" />
the javscript switcher
mWebView.getSettings().setJavaScriptEnabled(true);
and then my all code:
the java
package xiamubobby.inoroy.androidtest;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
public class WebViewDemo extends Activity {
private WebView mWebView;
#Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
mWebView = (WebView) findViewById(R.id.webView);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("http://www.google.com");
}
}
the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xiamubobby.inoroy.androidtest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:label="#string/app_name"
android:name=".AndroidtestActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
the main.xml
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Can anybody tell me what I did wrong? I am hoping for rescue.
Since I'm not a very experienced programmer, maybe there be very silly mistakes. Thank you for your patience.

if WebViewDemo is your start activity then you have to change your AndroidManifest.xml: replace android:name=".AndroidtestActivity" with android:name=".WebViewDemo"

Related

Imposible to develop a simple android app using Google Map API V2

I would like to use a Google Map in my current application. Before integrate it to my app, I created a test project to understand the functionalities.
I read this : https://developers.google.com/maps/documentation/android/start#installing_the_google_maps_android_v2_api
and this :
http://developer.android.com/google/play-services/setup.html#
After a lot of problems with these errors :
didn't find class com.google.android.gms.maps.MapFragment
and
Found 2 versions of android-support-v4.jar in the dependency list,
but not all the versions are identical (check is based on SHA-1 only at this time)
When I run my project, Eclipse says "Launching Test:(99%)", then my computer temperature up to 100°C and Eclipse take 512% of my CPU ! So I'm obliged to force Eclipse to quit.
I spent a lot of time on stack overflow, rebuild, clean, add support library, delete project and recreate from the beginning etc.
Help me, I just want to create a basic app to test a GoogleMap !
My code :
MainActivity.java
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!--
The following two permissions are not required to use
Google Maps Android API v2, but are recommended.
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<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" >
<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.google.android.maps.v2.API_KEY"
android:value="***" />
</application>
</manifest>
Edit : I know now that the problem appears when I reference the google-play-services_lib to my project... Any ideas ?
public class YourActivity extends FragmentActivity {
GoogleMap map;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_activity);
map =((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.iqamah_map)).getMap();
}
}
your xml :
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/iqamah_map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment" />
Add this in your Manifest
<uses-permission android:name="com.example.test.permission.MAPS_RECEIVE" />
<uses-library android:name="com.google.android.maps" />
Even me having the same issue, then instead of getting API key from Google Map Android V2, i took the API key from Google Maps Embed API and included in the Manifest and solved my problem.
Proof:
1.API key i took for project
2.Used Key in Manifest.xml

Android App can't save data to Parse

I have created a sample app called NoteApp, that can save data to Parse. I have created the app in Parse as per the image below, and have created the app..which is still in progress.
I have created the object"testObject", I have matched the ID, and imported data(Ctrl+Shift+O)but when I try to run the app, and check the Parse dashboard, I can't see the object being created. I have tried this so many times, I don't know where the problem is. I just can't link my android app in eclipse with the Parse.com. the app can't create the object, hence I can't save data.
Here is the Application code, and the manifest file, and the image of the Parse.com Dashboard.
NoteApplication.java
package com.echessa.noteapp;![enter image description here][1]
import android.app.Application;
import com.parse.Parse;
import com.parse.ParseObject;
public class NoteApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
Parse.initialize(NoteApplication.this, "XXXXXXXXXXXXXXXX","XXXXXXXXXXXXXXXXXX");
ParseObject testObject = new ParseObject("TestObject");
testObject.put("foo", "bar");
testObject.saveInBackground();
}
}
The Manifest File
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.echessa.noteapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name="com.echessa.noteapp.NoteApplication"
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" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Android file crashes on emulator and on physical device while requesting URL from Google Images

I know many of you will say "check your settings when creating the project," but I did. I checked and my physical device (Samsung S3) uses Android 4.3 and I set the minimum requirement to 2.2 and target to 4.3. I think it might be my code because I've been able to run other Android applications using the eclipse ADT emulator I just never tried it on an actual device and it just doesn't even show up in my emulator.
Here is my java code:
package com.example.bitmapdisplay;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.widget.ImageView;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
URL req = new URL("http://i1.cpcache.com/product_zoom/617914535/dickbutt_2_mug.jpg? side=Back&height=250&width=250&padToSquare=true");
ImageView image = (ImageView) findViewById(R.id.ivImage);
Bitmap mIcon_val= BitmapFactory.decodeStream(req.openConnection()
.getInputStream());
image.setImageBitmap(mIcon_val);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Here is my XML layout file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${packageName}.${activityClass}" >
<ImageView
android:id="#+id/ivImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
</RelativeLayout>
Here is my XML Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bitmapdisplay"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity android:name="com.example.bitmapdisplay.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>
Need to look at the logCat for more info but one problem that i can see in your manifest is that you have intent-filters missing. Inside your application
android.intent.category.MAIN is given to the activity wich is going to launch at first.
Try this:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Add these two lines to your activity tab and this will tell android this is the main starting activity.
whether the message appears in the console messages like this example? :
uploading your.apk onto device '0123456789ABCDEF'
installing your.apk
starting activity

MapActivity :Couldn't get connection factory client

I am trying to use google map for my android application but all i get is grey grids and in logcat it shows error like :
02-11 09:49:56.860: E/MapActivity(979): Couldn't get connection factory client
I have added permission in manifest to use internet.
I have used google library.
I have used Correct Map Api key for android application.
I am using correct emulator to support google API
Browser in my emulator is working and connecting to internet but my App is not working even on android mobile!
here is my manifest file code :
package="com.nawed.maps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<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" >
<uses-library android:name="com.google.android.maps"/>
<activity
android:name="com.nawed.maps.ShowMap"
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>
My activity class :
package com.nawed.maps;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;
public class ShowMap extends MapActivity {
MapView mapView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show_map);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
}
#Override
protected boolean isRouteDisplayed() {
return false;
}
}
My XML file :
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="MyKey"
/>
I have seen other repeated questions but it doesn't worked for me.
Thank you in advance.

Google map is blank, only zoom shows

I am trying to embed Google Maps into my app. Below is my xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:name="com.google.android.gms.maps.SupportMapFragment"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
</LinearLayout>
Here is the main class file:
package com.em.basicmap;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Here is my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.em.basimap"
android:versionCode="1"
android:versionName="1.0" >
<permission android:name="com.em.MAPS_RECIEVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.em.MAPS_RECIEVE"/>
<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.google.android.providers.gsf.permissions.READ_GSERVICES"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<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.em.basicmap.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.maps.v2.API_KEY"
android:value="AIzaSyCrstFrx_Mj8PaBJYtSH6bk62kggzstYzM"/>
</application>
</manifest>
I have tried everything I can think of. I have made sure that I have Google Maps Android API in the google apis. I have renewed my debugging key many times, I have downloaded the google-play services and I have copied the lib jar into my directory. I have ensure that my target sdk is Google api 17, I have included all of the permissions that I could find that I might need. I've looked all over StackOverflow for help, and the above are the help that I could find, but my app still displays a blank screen and zoom buttons. I'm really at a loss for what to do now. Are there some other things I have not done correctly? How might my access my SHA1 code? I have done it through the command line and eclipse, but my logcat says that it may still be an authorization issue.
public class MapsActivity extends FragmentActivity
{
GoogleMap gm;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.maps);
gm = ((SupportMapFragment) (getSupportFragmentManager()
.findFragmentById(R.id.map))).getMap();
gm.setMapType(GoogleMap.MAP_TYPE_NORMAL);
gm.setMyLocationEnabled(true);
}
}
There are two keys.Debug and release key. Release key procedure,you can refer here.
Google Map Android API v2 can't display map in play store application
In your MainActivity you will have to load the GoogleMap. Just putting fragment in xml file doesn't going to load the map.
Try out as below:
public class MainActivity extends FragmentActivity {
private GoogleMap mMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Do a null check to confirm that we have not already instantiated the map.
if (mMap == null) {
// Try to obtain the map from the SupportMapFragment.
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
// Check if we were successful in obtaining the map.
if (mMap != null) {
mMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
}
}
}
}
Your manifest looks right. It's definitely a problem with your key.
In the api console, under services, make sure you have selected Google Maps Android API v2 and not Google Maps API v3. Also, make sure you have appended your package name to your key and that your are generating your SHA-1 on the same key that you are signing with. If this is debug mode, use:
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore -list -v
If release mode use your release keystore.
So it is problem with your API key, create new API key with your SHA-1 key and package name(mentioned in Android manifest.xml) separated with semi column.
See here,just change the api key with your key in manifest file and follow these steps:
and make sure that your google_play_services_lib project should be present in your project's work space only.
Manifest file:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<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" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.geeklabs.map.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.maps.v2.API_KEY"
android:value="replace with your API key"/>
</application>
</manifest>
MainActivity.java:
package com.geeklabs.map;
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);
}
}
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
After got this let me know.

Categories

Resources