[android-developers] SAX parser crashes with Permision Denied exeption message when retriving google weather XML.

2011-06-22 Thread ferran fabregas
Hi! I'm trying to get the current temperature via google weather with SAX
Parser but i get a permision denied exeption message when i try to get
data:

Code:

/* Get what user typed to the EditText. */
String cityParamString = ((EditText)
findViewById(R.id.edit_input)).getText().toString();
String queryString = http://www.google.com/ig/api?weather=+
cityParamString;
 /* Replace blanks with HTML-Equivalent. */
 url = new URL(queryString.replace( , %20));
 /* Get a SAXParser from the SAXPArserFactory. */
 SAXParserFactory spf = SAXParserFactory.newInstance();
 SAXParser sp = spf.newSAXParser();
  /* Get the XMLReader of the SAXParser we created. */
  XMLReader xr = sp.getXMLReader();
 /* Create a new ContentHandler and apply it to the XML-Reader */
  GoogleWeatherHandler gwh = new GoogleWeatherHandler();
 xr.setContentHandler(gwh);
 /* Parse the xml-data our URL-call returned. */
 xr.parse(new InputSource(url.openStream()));  THIS CRASHES WITH
PERMISION DENIED EXCEPTION MESSAGE

The url seems to be find, but url.openstream dosn't work

Any Idea?

Thanks in advance

*Ferran*

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Android Market: issue uploading image assets

2011-05-05 Thread ferran fabregas
Hi! When I try to upload the app high resolution icon image o app screen
capture to android market, browser give me next error:

Unable to parse response. If you have a browser extension or add-on
installedwhich changes the JSON response, please disable and refresh this
page.

I've tried with Firefox, chrome and IE8, and dosn't work...

Any Ideas?

Thanks in advance,
*Ferran*

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: How to know if is the first execution after device reboot.

2011-05-05 Thread ferran
Thanks! I've done it with a reciver attending ACTION_SHUTDOWN signal,
and using shared preferences to save the state.

Sorry, i'm newbie and I'm learning...

On May 4, 11:47 pm, Justin Anderson magouyaw...@gmail.com wrote:
 * Hi! I want to know if there are any method to know if is the first
 exuction of an app after reboot, or the app is alredy executed by the user
 (the app have one activity and to recivers).*
 *
 *
 Is this for an application you developed or any arbitrary app?  And, WHY?

 * I'm thinking in methods like write and rewrite a token file every minute,
 and each time the app starts, check the lastmodified property to know the
 state, but i think that must be smart ways to do it.*

 Please tell me you're not serious... You're joking right?  Writing a file
 every minute in the background would surely drain the battery like crazy.

 A better solution, if you really want to know the first time your app is
 launched after a reboot is to listen for the Boot Completed broadcast
 message:http://developer.android.com/reference/android/content/Intent.html#AC...

 Have your receiver write out a value to SharedPreferences... something like
 a boolean key/value pair with a key of LaunchedSinceBoot and a value of
 false

 Then when you launch your main app read that value and act accordingly.
  Then set the value to true so the next time you launch you skip the
 first-launch-since-boot steps...

 Thanks,
 Justin Anderson
 MagouyaWare Developerhttp://sites.google.com/site/magouyaware







 On Wed, May 4, 2011 at 5:34 AM, ferran fabregas ferri...@gmail.com wrote:
  Hi! I want to know if there are any method to know if is the first exuction
  of an app after reboot, or the app is alredy executed by the user (the app
  have one activity and to recivers).

  I'm thinking in methods like write and rewrite a token file every minute,
  and each time the app starts, check the lastmodified property to know the
  state, but i think that must be smart ways to do it.

  Any idea?

  Thanks in advance,

  *Ferran*

   --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] How to know if is the first execution after device reboot.

2011-05-04 Thread ferran fabregas
Hi! I want to know if there are any method to know if is the first exuction
of an app after reboot, or the app is alredy executed by the user (the app
have one activity and to recivers).

I'm thinking in methods like write and rewrite a token file every minute,
and each time the app starts, check the lastmodified property to know the
state, but i think that must be smart ways to do it.

Any idea?

Thanks in advance,

*Ferran*

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Download large file from network to SD card

2010-11-02 Thread Ferran Garriga Ollé
I'm trying to download a large .zip file from a web server but I have
a weird behaviour, the description is:

 - I'm executing the code in the device emulator, API level 3 (version
1.5) with an SD card of 512MB. I start the device with Wipe data
user
 - The length of the size from conexion.getContentLength() is 7012725
 - The server address is localhost (10.0.2.2), but I've tried with an
external server and the behaviour is the same. I've double checked
that I can download the file through a web browser.
 - I have these permisions in the manifest file:

uses-permission android:name=android.permission.INTERNET/uses-
permission
uses-permission
android:name=android.permission.WRITE_EXTERNAL_STORAGE/uses-
permission

The error:

 - It starts downloading the file, I can see the text 10, 20, 30, 40,
50 and then it stops at 60.
 - After a while, the emulator reboots itself.

Workarounds:

  - About the possible wifi lock, what I've done is add this
permission android.permission.WAKE_LOCK and then this piece of code,
but with exactly the same behaviour:

WifiManager.WifiLock wifilock;
WifiManager manager = (WifiManager)
getSystemService(Context.WIFI_SERVICE);
wifilock = manager.createWifiLock(wifilock);
wifilock.acquire();
...
wifilock.release();

Here is the code, that it's being executing in a separate thread:

private void downloadData(){
try{
Log.v(TAG, downloading data);

URL url  = new URL(http://10.0.2.2/1.zip;);
URLConnection conexion = url.openConnection();
conexion.connect();

int lenghtOfFile = conexion.getContentLength();

Log.v(TAG, lenghtOfFile = +lenghtOfFile);

InputStream is = url.openStream();

File testDirectory = new
File(Environment.getExternalStorageDirectory()+/testDirectory/);
if(!testDirectory.exists()){
testDirectory.mkdir();
}

FileOutputStream fos = new 
FileOutputStream(testDirectory+/
files.zip);

byte data[] = new byte[1024];

int count = 0;
long total = 0;
int progress = 0;

while ((count=is.read(data)) != -1)
{
total += count;
int progress_temp = (int)total*100/lenghtOfFile;
if(progress_temp%10 == 0  progress != 
progress_temp){
progress = progress_temp;
Log.v(TAG, total = +progress);
}
fos.write(data, 0, count);
}

is.close();
fos.close();

Log.v(TAG, downloading finished);

}catch(Exception e){
Log.v(TAG, exception in downloadData);
e.printStackTrace();
}

}

** more log description:**

00:00 It starts downloading:
V/iPhoto  (  853): downloading data
V/iPhoto  (  853): lenghtOfFile = 7732809
V/iPhoto  (  853): total = 10
V/iPhoto  (  853): total = 20
V/iPhoto  (  853): total = 30
V/iPhoto  (  853): total = 40
V/iPhoto  (  853): total = 50 (round 00:05)
- Here it stops and the DDMS disconnects the device immediatly

03:40 It finish the download (not always) and the device reboots
on its own:
I/Process (  595): Sending signal. PID: 595 SIG: 3
I/dalvikvm(  595): threadid=7: reacting to signal 3
D/dalvikvm(  722): GC freed 2193 objects / 135808 bytes in 176 sec
V/iPhoto  (  853): total = 60
I/dalvikvm(  595): Wrote stack trace to '/data/anr/traces.txt'
I/ActivityManager(  595): Process
com.google.android.apps.maps:FriendService (pid 778) has died.
I/ActivityManager(  595): Process com.android.mms (pid 732) has
died.
V/iPhoto  (  853): total = 70
V/iPhoto  (  853): total = 80
V/iPhoto  (  853): total = 90
V/iPhoto  (  853): total = 100
V/iPhoto  (  853): downloading finished
V/iPhoto  (  853): thread finish loading
I/Process (  595): Sending signal. PID: 595 SIG: 9
I/ActivityThread(  757): Removing dead content provider: settings
I/ActivityThread(  748): Removing dead content provider: settings
I/ActivityThread(  722): Removing dead content provider: settings
I/ActivityThread(  700): Removing dead content provider: settings
I/ServiceManager(  549): service 'package' died
... services dieing...
I/ServiceManager(  549): service 'wifi' died
E/installd(  557): eof
E/installd(  557): failed to read size
I/installd(  557): closing connection
D/qemud   (  560): fdhandler_event: disconnect on fd 11

[android-developers] HorizontalScrollView XML starting scrolled to LEFT

2009-11-18 Thread Ferran Garriga Ollé
Hi,

When you define by XML an HorizontalScrollView, inside it a
LinearLayout with several items, if there are too many items, you will
be able to scroll it.

This scrolls by default, go from left to right, the first item is on
the left and the last item cutet because is doesn´t fit on he right.

What I need is to set the scroll completely scrollet into the right,
where you have the element cutet on your left. Like if you had done
the scroll by yourself, but I need to declare it into the XML.

I´ve tried to use android:scrollX=200px but it does´t work.

Any idea?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] HorizontalScrollView XML starting scrolled to RIGHT instead of left

2009-11-18 Thread Ferran Garriga Ollé
Hi,

When you define by XML an HorizontalScrollView, inside it a
LinearLayout with several items, if there are too many items, you will
be able to scroll it.

This scrolls by default, go from left to right, the first item is on
the left and the last item cutet because is doesn´t fit on he right.

What I need is to set the scroll completely scrollet into the right,
where you have the element cutet on your left. Like if you had done
the scroll by yourself, but I need to declare it into the XML.

I´ve tried to use android:scrollX=200px but it does´t work.

Any idea?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Gestures overlay layout on API Level 3

2009-11-09 Thread Ferran Garriga Ollé
Hi,

I'm trying to implement a very simple gesture (vertical finger motion)
on an app that have several layouts (LinearLayout), as example:

global layout full screen
¦-- children
¦-- children
¦ children
¦ children
¦-- children

If I set onTouch on my global layout, it works if I only touch the
piece of the screen not overlapped by the children, but what I need is
to detect the touch in the whole layout boundary, overlaying the
children.

I think that what I need is the GestureOverlayView equivalent on the
API Level 3, there are any solution on this?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en