I need to register with app on my tablet, but when I press the button "register" I get ConnectionException: Connection refused.
This is my endpoint:
public static String URL_REGISTER = "http://192.168.1.129/android_login_api/register.php";
MANIFEST:
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>
I don't know why it doesn't work!
Can someone help me?
Related
I have used this code to send an mms and all parameters are correct, but the connection is refused.. And the netWork is connected on mobile mms.
HttpUtils is a class from a library downloaded here : https://github.com/android/platform_packages_apps_mms
HttpUtils.httpConnection(getApplicationContext(), 4444L, MMSCenterUrl, bytesToSendFromPDU, HttpUtils.HTTP_POST_METHOD, !TextUtils.isEmpty(MMSProxy), MMSProxy, port);
06-29 19:51:26.208: I/Log MMSCenterUrl(13071): http: //mmsnrj
06-29 19:51:26.208: I/Log MMSProxy(13071): 10.143.156.5
06-29 19:51:26.208: I/Log MMSPort(13071): 8080
06-29 19:51:26.288: E/Mms:transaction(13071): Url: http: //mmsnrj
06-29 19:51:26.288: E/Mms:transaction(13071): Connection to http: //10.143.156.5:8080 refused
Manifiest file :
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
Crossing out usual suspects
Uses Internet permission in manifest file
Server is actually up.Please send a post request form the browser using Post master or any such tool
10.143.156.5 ip seems its an external system. Ensure that firewalls are not making your development life miserable. (Port forwarding or open the port on the routers)
I'm trying to show a simple google map on my real Samsung device where Android version is 2.3.4.
got my SHA1 key
got my API key from google
Here is my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.neighbourhoodlocator"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!-- External storage for caching. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- My Location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Maps API needs OpenGL ES 2.0. -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyBq8ATEI-DmBtso1T13S_DGfiT7cBgEav8" />
<activity
android:name="com.neighbourhoodlocator.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>
Here is my main.xml 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"
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" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
</RelativeLayout>
Here is my Mainactivity.java file:
public class MainActivity extends FragmentActivity {
#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.main, menu);
return true;
}
}
Now the issue I'm having when I launch it on the real device, it doesn't crash, nor it throws any exception (No "Invalid Authorization" either); only thing I can see on the screen is a blank (gray box) with "+" and "-" button. I've tried Activity instead of FragmentActivity, application crashed.
I checked the logcat trace:
10-12 23:14:34.989: W/dalvikvm(15055): VFY: unable to resolve instance field 28
10-12 23:14:35.119: W/dalvikvm(15055): Unable to resolve superclass of Lmaps/p/w; (743)
10-12 23:14:35.119: W/dalvikvm(15055): Link of class 'Lmaps/p/w;' failed
10-12 23:14:35.119: W/dalvikvm(15055): Unable to resolve superclass of Lmaps/ap/as; (6267)
10-12 23:14:35.119: W/dalvikvm(15055): Link of class 'Lmaps/ap/as;' failed
10-12 23:14:35.139: W/dalvikvm(15055): Unable to resolve superclass of Lmaps/af/k; (5294)
10-12 23:14:35.139: W/dalvikvm(15055): Link of class 'Lmaps/af/k;' failed
10-12 23:14:35.139: E/dalvikvm(15055): Could not find class 'maps.af.k', referenced from method maps.ag.an.a
10-12 23:14:35.139: W/dalvikvm(15055): VFY: unable to resolve new-instance 5139 (Lmaps/af/k;) in Lmaps/ag/an;
I added the google-play-services_lib appropriately. and also added the android-support-v4.jar is also in "Android private libraries".
Notice that the project build target is: Google APIs 4.2.2
and the android version in my Samsung phone is: 2.3.4
I've been trying last couple of days, I also tried in the emulator, same thing is happening.
Please help me to solve the issue.
Thanks.
I had a similar problem.. I have solved it. Android emulators aren't working. You should work your app on your phone. When exporting your project, your sha1 is changing. You must copy that sha1 and make a new API-KEY in google api console. (don't forget the change manifest file). After uploading your phone, it works..
I'm trying to connect to a web app running my computer from the android emulator using the apache httpClient.
HttpPost post = new HttpPost("http://dev.example.com:8443/gatekeeper/rs/authenticate/login");
post.setHeader("Content-type","application/x-www-form-urlencoded");
post.setEntity(new UrlEncodedFormEntity(formparams));
HttpClient client=new DefaultHttpClient();
response = client.execute(post);
I do have the required android manifest configuration as below
<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="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
I did check I can access the internet from the browser on the emulator. I can not access the app URL from the browser as well. My application also fails with an error
java.net.UnknownHostException: Unable to resolve host
"dev.example.com": No address associated with hostname
My application works fine when used with IP address of my computer. I also have entry in my hosts file
192.168.1.8 dev.example.com
What can I be missing here? It looks like android emulator can't look in to my hosts file to resolve the host name!
Please check the Connectivity programitically before calling for response
or If there is no response the also this exception is thrown
Working on an Android application...
I'm getting this error message:
i/o failure: java.net.UnKnownHostException: Unable to resolve host
"api.parse.com": No address associated with hostname
Many suggest to add internet permission in the manifest file, I have these permissions already:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Any suggestions?
Thanks!
I'm guessing that the device is
not connected to the private LAN that has
the DNS server that resolves the hostname. The emulator shares the network
connectivity of its host; not so the
real device.
The error says that the dns server the device is talking to can't resolve
the name. It may also mean we can't talk to the dns server.
You have these two entries in AndroidManifest.xml file:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
I don't think there might be other reason for that except the connection.
EDIT :
I transferred my 20+ projects that tries to use Google Maps for Android v2. After changing keys and stuff, now, it works. I don't know what made this work, but thank you all. I got one keystore, the key is right. I guess it magically fixed somehow. Well, thanks guys.
I'm doing searches for 2 days and I couldn't fix this problem. I did everything, yet, this application can not work.
I want my application to work on Android 2.2 and above. Like it says "if you create your app in level 8, it'll support 95% of market".
Here are my screenshots and source codes:
I'm pasting the source code which is the easiest to get. I took this from web.
Here's the output of the command
keytool -list -keystore <path>
***************** WARNING WARNING WARNING *****************
* The integrity of the information stored in your keystore *
* has NOT been verified! In order to verify its integrity, *
* you must provide your keystore password. *
***************** WARNING WARNING WARNING *****************
Keystore type: JKS Keystore provider: SUN
Your keystore contains 1 entry
androiddebugkey, 15.Mar.2013, PrivateKeyEntry,
Certificate fingerprint (SHA1): xxx
main.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="AIzaSyDim-x5Gxxx"
/>
manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidhive.googlemaps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<!-- Add Google Map Library -->
<uses-library android:name="com.google.android.maps" />
<activity
android:name=".AndroidGoogleMapsActivity"
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>
<!-- Allow to connect with internet -->
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
java file (no need to paste it all, but I guess it's best to paste it all)
http://pastebin.com/yF95Rcbd
Here are my screenshots:
http://i.imgur.com/gExHpUG.png
http://i.imgur.com/AMOXKhr.png
http://i.imgur.com/Aqon97Y.png
I'm trying to compile this app to Android 4.2.2, but I tried and want to make it work in 2.2 and above.
Here's the Android tab of the properties window just to make sure:
http://i.imgur.com/ht0CQwT.png
Here's my log
03-20 07:01:20.145: W/System.err(956): at java.lang.Thread.run(Thread.java:856)
03-20 07:01:20.665: W/System.err(956): IOException processing: 26
03-20 07:01:20.665: W/System.err(956): java.io.IOException: Server returned: 3
03-20 07:01:20.665: W/System.err(956): at android_maps_conflict_avoidance.com.google.googlenav.map.BaseTileRequest.readResponseData(BaseTileRequest.java:115)
03-20 07:01:20.675: W/System.err(956): at android_maps_conflict_avoidance.com.google.googlenav.map.MapService$MapTileRequest.readResponseData(MapService.java:1473)
03-20 07:01:20.675: W/System.err(956): at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.processDataRequest(DataRequestDispatcher.java:1117)
03-20 07:01:20.675: W/System.err(956): at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.serviceRequests(DataRequestDispatcher.java:994)
03-20 07:01:20.675: W/System.err(956): at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher$DispatcherServer.run(DataRequestDispatcher.java:1702)
These lines repeat all the time.
Thank you very much.
Your post appears to contain code that is not properly formatted as code" error made
me delete the blank lines. Sorry for the messed up codes.
http://i.imgur.com/ht0CQwT.png
See the snapshot. You did not add Google Play Services library that is require for displaying Google Android Map V2. Please download and add that library and then try again.
Please also see the target. Your target is 4.2.2 and your are accessing it on 2.2. Change the target to 2.2 and use support fragment.
Thanks,
I have solved this issue,
Open your Google APIs Console
Choose API Access
Edit allowed Android apps from your API Key
Change the package name with your package name
Example: 00:06:A5:0E:04:A2:1E:8F:FE:6B:7F:46:23:C3:xx:xx:xx:xx:xx:xx;com.example.androidmapview
You are missing permissions and meta-data for API KEY.
Read this carefully: https://developers.google.com/maps/documentation/android/start
Working with android mapapi v2 ,the main reason is you must add play service to your app,like below :
<permission
android:name="com.example.androidmapview.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.androidmapview.permission.MAPS_RECEIVE" />
Use fragment class in Layout:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
And change your manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.androidmapview"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<permission
android:name="com.example.androidmapview.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.androidmapview.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<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-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.androidmapview.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="AIzxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"></meta-data>
</application>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
</manifest>
in activity:
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.SupportMapFragment;
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SupportMapFragment fragment = new SupportMapFragment();
getSupportFragmentManager().beginTransaction()
.add(android.R.id.content, fragment).commit();
}
}
For more info check the link which will explain you in details about api v2
I solved my blank screen problem with zoom in/out buttons like that.(it happens after I changed my package name)
Delete the keystore file
Create a new keystore file
Get SHA1 fingerprint
Go to API Console
Create a new Android App.
Paste your fingerprint
Use the given API Key in your Manifest File
That worked for me