Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

Monday, 14 August 2017

How to debug your Android application on an Archos 7 internet tablet ~ foundjava

You can find information on how to debug on a real device on the Using Hardware Devices page. But since this is missing information about the Archos Internet Table 7 (the device I am using) I will post here how you can do it (on Windows).
First of all you need to download the Archos ADB drivers from the archos site. Install it by following the instructions on the Google USB Driver page.
Then you need to edit the adb_usb.ini file (it should be in your home directory, under the .android folder) and add the following line: 0x0e79. You should get something like the following:
# ANDROID 3RD PARTY USB VENDOR ID LIST -- DO NOT EDIT.
# USE 'android update adb' TO GENERATE.
# 1 USB VENDOR ID PER LINE.
0x0e79
You must kill and restart the adb server by running: adb kill-server and adb start-server (adbis in android-sdk\platform-tools). You can also run adb devices to make sure your device is listed. You should see something like the following:
List of devices attached
A70-3A860001-9FF80000-015DB7D4-???????? device
(the ?????? is probably a name in non-Latin characters that the command window does not recognise).
Once you’ve set it up configure your application and your device to be debugable by following the instructions on the Using Hardware Devices page.
If you have done everything correctly next time you run Eclipse you should see that it’s synchronising the application to your device
[2012-02-27 19:44:16 - Lexicon] Performing sync
[2012-02-27 19:44:16 - Lexicon] Automatic Target Mode: using device 'A70-3A860001-9FF80000-015DB7D4-????????'
[2012-02-27 19:44:16 - Lexicon] Uploading TestApp.apk onto device 'A70-3A860001-9FF80000-015DB7D4-????????'
[2012-02-27 19:44:17 - Lexicon] Installing TestApp.apk...
[2012-02-27 19:44:25 - Lexicon] Success!
[2012-02-27 19:44:26 - Lexicon] \TestApp\bin\TestApp.apk installed on device
[2012-02-27 19:44:26 - Lexicon] Done!
You are ready to start debugging your application on a real android device.
Read More »

Sunday, 13 August 2017

Lexicon ~ foundjava

Lately I have started doing some Android development. I have written a small application called “Lexicon” which you can find on Google Play. It works with Android version 2.2 and above. It’s a dictionary which you can use from any application that has “share text” capabilities. I’d appreciate if you can download it (it’s free) and test it on your device (I have only tested it with Android 2.2 and 2.3). If you do download it please read the release notes. Please let me know of any bugs or errors you find.
Thank you.
Read More »

Android INSTALL_FAILED_CONTAINER_ERROR on installing an application ~ foundjava

I got this error while I rebooted my android device in the middle of installing an application (it was taking ages so I assumed that it was stuck). It seems that android did not have time to clean the file system, so every time i was trying to install an application I was getting the error:
ASEC file ‘/mnt/secure/asec/smdl2tmp1.asec’ currently exists – destroy it first! (Address already in use)
The solution to this is actually very simple. Make sure that you have connected your device to your computer and that it’s running on debug mode (it’s not mounted). Open a command window, go to your Android\android-sdk\platform-tools and type adb shell. This should open the adb shell and connect as root. Then simply type rm /mnt/secure/asec/smdl2tmp1.asec and the problem should go away.
Read More »

How to call a web service from Android ~ foundjava

By far the easiest way is to use the ksoap2-android API. You need the ksoap2 jar file (with all dependencies) which can be found here and you need to add this to your classpath. In the following sample code we call a free web service, called currency convertor, which has one operation (method) that is is called ConversionRate. If you look at the service dscription (the WSDL file), you will see that this operation takes two parameters, FromCurrency and ToCurrency. Lets say that we want to find out the conversion rate from USD to EUR. We implement the following Activity
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package gr.panos.caller;
 
import java.io.IOException;
 
import org.ksoap2.SoapEnvelope;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;
 
import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.widget.TextView;
 
public class ConvertorCaller extends Activity {
 
    public static final String NAMESPACE = "http://www.webserviceX.NET/";
    public static final String SOAP_ACTION = "http://www.webserviceX.NET/ConversionRate";
    private static final String METHOD = "ConversionRate";
    private TextView textView;
     
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_convertor_caller);
        textView = (TextView) findViewById(R.id.textView1);
        AsyncTaskRunner runner = new AsyncTaskRunner();
        runner.execute();
    }
 
     private class AsyncTaskRunner extends AsyncTask<String, String, String>{
 
         private String resp;
 
        @Override
        protected String doInBackground(String... params) {
             try {
              SoapObject request = new SoapObject(NAMESPACE, METHOD);
              request.addProperty("FromCurrency", "USD");
              request.addProperty("ToCurrency", "EUR");
 
              SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
              envelope.dotNet = true;
              envelope.setOutputSoapObject(request); 
              System.out.println("************ I AM SENDING: " + envelope.bodyOut);
               
               HttpTransportSE transport = new HttpTransportSE(URL);
               try {
                 transport.call(SOAP_ACTION, envelope);
               } catch (IOException e) {
                 e.printStackTrace();
               } catch (XmlPullParserException e) {
                 e.printStackTrace();
             }
           if (envelope.bodyIn != null) {
               if (envelope.bodyIn instanceof SoapFault) {
                   String s = ((SoapFault) envelope.bodyIn).faultstring;
                   System.out.println("************ ERROR: " + s);
                   resp = s;
               } else if (envelope.bodyIn instanceof SoapObject) {
                   SoapObject obj = ((SoapObject) envelope.bodyIn);
                   System.out.println("**** RESPONSE: " +obj);
                    
                   SoapPrimitive root = (SoapPrimitive) obj.getProperty(0);
                   System.out.println("**** CONVERSION RATE: " +root.toString());
                    
                   resp = root.toString();
               }
                    
           }
         } catch (Exception e) {
           e.printStackTrace();
           resp = e.getMessage();
         }
         return resp;
       }
 
          /**
           *
           * @see android.os.AsyncTask#onPostExecute(java.lang.Object)
           */
          @Override
          protected void onPostExecute(String result) {
              textView.setText(resp);
          }
     
          /**
           *
           * @see android.os.AsyncTask#onPreExecute()
           */
          @Override
          protected void onPreExecute() {
          }
          /**
           *
           * @see android.os.AsyncTask#onProgressUpdate(Progress[])
           */
          @Override
          protected void onProgressUpdate(String... text) {
          }
    }
 
}
You also need to define a text view in your layout as well as give the activity INTERNET permission in your manifest file.
Read More »