Is there any way to use the socket port lower than 1024 (eg. 223) in Android platform

by sharon....@gmail.com » Sun, 15 Mar 2009 13:13:54 GMT


Sponsored Links
 Is there any way to use the socket port lower than 1024 with class
MulticastSocket? My application has to use this port to receive data
from other official tool which I can not change.  But
java.net.BindException happend when I new a MulticastSocket instance.
I've added INTERNET permission and I can create the socket if I change
it to other port bigger than 1023.

Source code : sock = New MulticastSocket(223)

Log:
I/System.out(  279): SocketException happend
W/System.err(  279): java.net.BindException: Permissions do not allow
action on socket
W/System.err(  279):    at
org.apache.harmony.luni.platform.OSNetworkSystem.socketBindImpl2
(Native Method)
W/System.err(  279):    at
org.apache.harmony.luni.platform.OSNetworkSystem.bind2
(OSNetworkSystem.java:145)
W/System.err(  279):    at
org.apache.harmony.luni.net.PlainDatagramSocketImpl.bind
(PlainDatagramSocketImpl.java:119)
W/System.err(  279):    at java.net.MulticastSocket.createSocket
(MulticastSocket.java:564)
W/System.err(  279):    at java.net.DatagramSocket.<init>
(DatagramSocket.java:82)
W/System.err(  279):    at java.net.MulticastSocket.<init>
(MulticastSocket.java:60)
W/System.err(  279):    at com.android.sockport.SocketPort.onCreate
(SocketPort.java:28)
W/System.err(  279):    at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1122)
W/System.err(  279):    at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2103)
W/System.err(  279):    at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2156)
W/System.err(  279):    at android.app.ActivityThread.access$1800
(ActivityThread.java:112)
W/System.err(  279):    at android.app.ActivityThread$H.handleMessage
(ActivityThread.java:1580)
W/System.err(  279):    at android.os.Handler.dispatchMessage
(Handler.java:88)
W/System.err(  279):    at android.os.Looper.loop(Looper.java:123)
W/System.err(  279):    at android.app.ActivityThread.main
(ActivityThread.java:3742)
W/System.err(  279):    at java.lang.reflect.Method.invokeNative
(Native Method)
W/System.err(  279):    at java.lang.reflect.Method.invoke(Method.java:
515)
W/System.err(  279):    at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:739)
W/System.err(  279):    at com.android.internal.os.ZygoteInit.main
(ZygoteInit.java:497)
W/System.err(  279):    at dalvik.system.NativeStart.main(Native
Method)

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. How to close one task in special

Hi All

How to close one task in special.

I can see the task with

ActivityManager manager =  (ActivityManager)this.getSystemService
(ACTIVITY_SERVICE );  ;
List<RunningTaskInfo> list = manager.getRunningTasks(10);
if (list.get(1).baseActivity.getShortClassName().equalsIgnoreCase
(".XXXX"))

thanks
David

-- 

2. Segfault in Bitmap.getPixel()

Hi,

I have a larger 512x512 32-bit ARGB Bitmap loaded from a PNG in my
application. I traverse each pixel in this bitmap as follows:

int height = bitmap.getHeight()-1;
for( int y = 0; y < bitmap.getHeight(); y++ )
{
   for( int x = 0; x < bitmap.getWidth(); x++ )
   {
      int pixel = bitmap.getPixel( x, y);
      collisionMap[x][height-y] =  pixel != -1 ?(byte)BACKGROUND_PIXEL:
0;
   }
}

I check each pixel in the bitmap for a specific color value and set a
byte in a corresponding 2D array that has the same dimensions as the
image. This works perfectly fine on my droid, on my hero as well as on
the emulator. I send the app containing this code to some other people
that have a g1 and a mytouch and there this few lines fail horribly
with a segfault:

02-01 17:47:25.532 I/ActivityManager(   74): Process
android.process.media (pid 3920) has died.
02-01 17:47:25.622 I/DEBUG   (   48): *** *** *** *** *** *** *** ***
*** *** *** *** *** *** *** ***
02-01 17:47:25.622 I/DEBUG   (   48): Build fingerprint: 'tmobile/opal/
sapphire/sapphire:1.6/DRC92/15632:user/ota-rel-keys,release-keys'
02-01 17:47:25.622 I/DEBUG   (   48): pid: 4033, tid: 4039  >>>
com.badlogic.doodleescape <<<
02-01 17:47:25.622 I/DEBUG   (   48): signal 7 (SIGBUS), fault addr
00000000
02-01 17:47:25.622 I/DEBUG   (   48):  r0 44527d84  r1 4622700a  r2
00000001  r3 00000000
02-01 17:47:25.622 I/DEBUG   (   48):  r4 00000001  r5 4622700a  r6
44527d84  r7 4104be78
02-01 17:47:25.622 I/DEBUG   (   48):  r8 44527d9c  r9 4104be6c  10
4104be5c  fp 00000001
02-01 17:47:25.622 I/DEBUG   (   48):  ip 4622700a  sp 44527d70  lr
ad346c1f  pc ad3469a0  cpsr 00000030
02-01 17:47:26.242 I/DEBUG   (   48):          #00  pc 000469a0  /
system/lib/libandroid_runtime.so
02-01 17:47:26.242 I/DEBUG   (   48):          #01  pc 00046c1c  /
system/lib/libandroid_runtime.so
02-01 17:47:26.242 I/DEBUG   (   48):          #02  pc 0000e434  /
system/lib/libdvm.so
02-01 17:47:26.252 I/DEBUG   (   48): stack:
02-01 17:47:26.252 I/DEBUG   (   48):     44527d30  ad083e1c  /system/
lib/libdvm.so
02-01 17:47:26.252 I/DEBUG   (   48):     44527d34  ad0159f4  /system/
lib/libdvm.so
02-01 17:47:26.252 I/DEBUG   (   48):     44527d38  0000032c
02-01 17:47:26.252 I/DEBUG   (   48):     44527d3c  0000002a
02-01 17:47:26.252 I/DEBUG   (   48):     44527d40  00000054
02-01 17:47:26.252 I/DEBUG   (   48):     44527d44  ad083e1c  /system/
lib/libdvm.so
02-01 17:47:26.252 I/DEBUG   (   48):     44527d48  00000064
02-01 17:47:26.262 I/DEBUG   (   48):     44527d4c  0000001a
02-01 17:47:26.262 I/DEBUG   (   48):     44527d50  00000000
02-01 17:47:26.262 I/DEBUG   (   48):     44527d54  4104be78
02-01 17:47:26.262 I/DEBUG   (   48):     44527d58  00000001
02-01 17:47:26.262 I/DEBUG   (   48):     44527d5c  41c3a728  /system/
framework/framework.odex
02-01 17:47:26.262 I/DEBUG   (   48):     44527d60  00000003
02-01 17:47:26.262 I/DEBUG   (   48):     44527d64  41c3a728  /system/
framework/framework.odex
02-01 17:47:26.262 I/DEBUG   (   48):     44527d68  df002777
02-01 17:47:26.262 I/DEBUG   (   48):     44527d6c  e3a070ad
02-01 17:47:26.262 I/DEBUG   (   48): #00 44527d70  ad346999  /system/
lib/libandroid_runtime.so
02-01 17:47:26.262 I/DEBUG   (   48):     44527d74  001aae00  [heap]
02-01 17:47:26.262 I/DEBUG   (   48):     44527d78  00000001
02-01 17:47:26.262 I/DEBUG   (   48):     44527d7c  ad346c1f  /system/
lib/libandroid_runtime.so
02-01 17:47:26.262 I/DEBUG   (   48): #01 44527d80  00000027
02-01 17:47:26.262 I/DEBUG   (   48):     44527d84  ffffffff
02-01 17:47:26.262 I/DEBUG   (   48):     44527d88  44527dc0
02-01 17:47:26.262 I/DEBUG   (   48):     44527d8c  00000004
02-01 17:47:26.262 I/DEBUG   (   48):     44527d90  ad346bed  /system/
lib/libandroid_runtime.so
02-01 17:47:26.262 I/DEBUG   (   48):     44527d94  ad00e438  /system/
lib/libdvm.so
02-01 17:47:28.122 I/ActivityManager(   74): Process
com.badlogic.doodleescape (pid 4033) has died.

The bitmap is loaded successfully otherwise i'd get a
NullPointerException when requesting its height in the first line of
code. It seems that Bitmap.getPixel() fails with a segfault.

I have not the slightest clou of what is happening here. The really
frightening part is that it works on the droid,hero and emulator but
not on g1 hardware. I'd really appreciate any pointers.

-- 

3. How to implement the long click event for the ExpandableListView

4. Problem with expandable list view

5. Querying the contacts content provider for values with accent

6. ArrayList items are missing

7. TableLayout will not draw new row addition