Android :: Determining What Bitmap Resource Was Loaded
Nov 14, 2010
I have created multiple bitmaps - one for each folder (mdpi, hdpi, ldpi). Can someone show me some code or point me to the appropriate method that will allow me to detect which resource Android decided to load.
View 4 Replies
Oct 19, 2010
Does all resource (all in res folder if on eclipse IDE), specially drawable image, is loaded to memory during runtime? Or it is just like a file which is available when the application need it?
View 1 Replies
View Related
Sep 11, 2010
I am loading a bitmap from a resource like so:
Bitmap mBackground = BitmapFactory.decodeResource(res,R.drawable.image);
What I want to do is make some changes to the bitmap before It gets drawn to the main canvas in my draw method (As it would seem wasteful to repeat lots of drawing in my main loop when it isn't going to change). I am making the changes to the bitmap with the following:
Canvas c = new Canvas(mBackground);
c.drawARGB(...); // etc
So naturally I get an exception
java.lang.IllegalStateException: Immutable bitmap passed to Canvas constructor
So to avoid that I made a copy of the bitmap so that it is mutable
Bitmap mBackground = BitmapFactory.decodeResource(res,R.drawable.image).copy(Bitmap.Config.ARGB_8888, true);
Which avoid the problem however it sometimes causes OutOfMemoryExceptions, do know any better ways of achieving what I want?
View 2 Replies
View Related
Nov 2, 2010
I have a bitmap that I want to display in my Android app.This works fine for platforms with version number greater than 1.5 but not for 1.5. When executing the line below an exception is thrown stating that the resource couldn't be found.
Bitmap bmp = BitmapFactory.decodeResource(mApplicationContext.getResources(), R.drawable.arrow);
I have put the bitmap in all density-folders (hdpi, mdpi, ldpi) and scaled them according to the documentation (the mdpi-bitmap is 25x25 pixels and the ldpi-bitmap size 75% of the mdpi-bitmap size and the hdpi-bitmap size 150% of the mdpi-bitmap size).
Any idea what is wrong here?
View 2 Replies
View Related
Nov 3, 2010
For some reason, when I create a bitmap from an image in asset, it does not display fullscreen. When I take an image from drawable, resId, the image shows fullscreen. Why is this?
CODE:..........................
View 1 Replies
View Related
Jul 21, 2010
I have a very large image and I only want to display a section the size of the display (no scaling), and the section should just be the center of the image. Because the image is very large I cannot read the entire image into memory and then crop it. This is what I have so far but it will give OutOfMemory for large images. Also I don't think inSampleSize applies because I want to crop the image, not lower the resolution.
Uri data = getIntent().getData();
Input Stream is = getContentResolver().openInputStream(data);
Bitmap bitmap = BitmapFactory.decodeStream(is, null, null);
Any help would be great?
View 3 Replies
View Related
Apr 2, 2009
I am 1) taking a picture and 2) then draw another Bitmap on top of it 3) then I store it
I am doing it as follows and it works on the emulator.
On the device I get a OutOfMemoryError: bitmap size exceeds VM budget android.graphics.Bitmap.nativeCopy(Native Method) android.graphics.Bitmap.copy(Bitmap.java:199) in the line copy the Bitmap to get a mutable Bitmap.
CODE:...........
What I am asking:
a) Is there a better way to do what I am doing? 1) take a picture 2) draw another Bitmap on top of it 3) then I store it
b) What is the best way to create a mutable Bitmap from the picture I just took with the camera?
In my app, resolution is not an issue. If it works better for small photos that would be fine.
View 3 Replies
View Related
Aug 3, 2010
I have an XML resource file:
<resources> <section>
<category value="1" resourceId="@xml/categoryData1" />
<category value="2" resourceId="@xml/categoryData2" />
<category value="3" resourceId="@xml/categoryData3" />
</section> </resources>
Using XmlPullParser, on the START_TAG, I can use:
int value = parser.getAttributeIntValue(null, "value", 0);
to get values 1, 2, 3...however:
int resourceId = parser.getAttributeIntValue(null, "resourceId", 0);
doesn't work...it just yields the default value 0, or whatever I change the default value (3rd parameter) to be. Does anyone know what I am doing wrong or if this is possible?
View 1 Replies
View Related
Oct 8, 2009
I have two questions actually:
Is it better to draw an image on a bitmap or create a bitmap as resource and then draw it over a bitmap? Performance wise... which one is better?
If I want to draw something transparent over a bitmap, how would I go about doing it?
If I want to overlay one transparent bitmap over another, how would I do it?
View 1 Replies
View Related
Mar 22, 2009
My goal is the draw a bitmap onto another bitmap but rotated 90 degress. whats the most efficient way to do that. My current method is as follows which is horribly bad because it creates a new bitmap every time.
CODE:.....................
View 4 Replies
View Related
Aug 25, 2010
How can I tell if a device is using HTC's SenseUI? I thought about using android.os.Build information, but they seem inconsistent. Is there a more definitive way? I need to be able to tell if I can launch the calendar by using com.android.calendar or com.htc.calendar.
View 1 Replies
View Related
Jun 28, 2010
My question is- with the telephony manager, is there a way to determine what number the phone is off hook with? I thought getLine1Number() might return that phone number that is being dialed, but it is not what I expect. I am working with 2 emulators, and added a log line so that I could see what that method is doing. When dialing another emulator, I expected getLine1Number() to return 5554, but it was 15555218135. Perhaps there is another method I should be using instead? Do I need to be into the source code to get the information I want?
View 1 Replies
View Related
Aug 18, 2009
I was wondering if there is a way to determine who passed an intent to my application. For example, I have a service, that I want to act differently depending on who passed the intent (for security reasons). I'm trying to sandbox each calling application, so they only have access to their data stored in my application.
For it to be secure, I cannot trust any application to be truthful about the identifying data it is passing into my service. Therefore, I need some system way of identifying who sent the intent in a way that the calling application cannot change that information. I don't know if it is possible, but I can't find anything in the Intent class, and I was wondering if there may be another structure which does what I want it to. If it is not possible, I would like to get some type of mechanism to do this in the roadmap.
View 13 Replies
View Related
Jul 19, 2010
I'm using a UNIX socket to facilitate communication on and Android device between a system level daemon I've got running in C and an application I've got running in Java. I'm much more of a C coder than a Java coder, so I'm having some issues when trying to read in data from the socket on the Java side. Currently, my code is as follows:
try{//Prepare to write the command and read the ACK
InputStream is = receiver.getInputStream();
OutputStream os = receiver.getOutputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(is));..............................
View 1 Replies
View Related
May 11, 2010
I looked over SensorManager and was still unsure, how do I detect if the phone is looking at true north (or any other direction for that matter).
View 1 Replies
View Related
Aug 6, 2010
How do you determine (programatically) if an Android device is: rooted Running a cracked copy of your software or rom. I have some sensitive information in my database, and I would like to encrypt it when the phone is rooted aka the user has access to the database. How do I detect that?
View 2 Replies
View Related
Nov 15, 2010
Is it possible to determine the unique bluetooth MAC address for an iPhone and an Android (and to a lesser extent, other smartphones) from within an app on said device? Is my assumption that the MAC address is universally unique correct? A general yes or no would be helpful. Example code in the case of an iPhone or an Android would be extremely helpful.
View 2 Replies
View Related
Jun 9, 2010
Question: How do you programmatically distinguish between directories and regular files in the assets folder?
When using AssetManager to access files in the assets folder, it seems impossible to determine if a file is in fact a file or a directory. You get the list of files from the list method and then open the file using the open method. I thought perhaps using the openFd method to get the asset file descriptor (and then subsequently requesting the normal file descriptor) would provide me some information. But requesting the file descriptor for a directory results in an IOException (which makes sense since what would it mean for a directory to have a file descriptor...?).
Currently I'm relying on that IOException (resulting from attemptng to open a directory in the assets folder) in order to determine if a file is in fact a directory. (Opening a regular file works just fine). This seems like a bad idea. Any other suggestions to distinguish between a file and a directory?
View 1 Replies
View Related
Apr 21, 2009
I am calling the ZXing scanner from Screen-A using intents. Once the scan is done control of course returns to the code behind Screen-A and I do some other work before calling Screen-B. Problem is the screen is black during this work period and I cannot determine the proper context to use to display a "working..." Toast/msgbox.
View 2 Replies
View Related
Jun 23, 2010
I'm working on an Android App where the user has different options for sorting the displayed data that comes from the database. Currently my orderBy string that I pass to Androids query() method looks like this:
"LOWER("+columnName+") ASC"
The problem with this is that if the data type in the column specified by columnName is integer, calling LOWER() on it will cause it to be sorted alphabetically, i.e. based only on the leftmost digit, which of course doesn't make any sense for numeric data. Hence I only want to apply LOWER() if the data type of the column is not integer. What I have in mind is a statement like this:
"CASE WHEN [data type of columnName is integer] THEN "+columnName+" ASC ELSE LOWER("+columName+") ASC END"
The part in the brackets is what I don't know how to do. Does SQLite provide a function to determine a column's data type?
View 3 Replies
View Related
Apr 4, 2010
I thought I'd share a script that I've been working on: http://www.anddev.org/viewtopic.php?p=30732
It lets you generate parameterizable histograms of Android Market sales by automatically downloading data from Google Checkout.
View 6 Replies
View Related
Jan 30, 2010
I wish to have one application that runs in the background, which knows when any of the built-in applications (messaging, contacts, etc) is running. So my questions are: How I should run my application in the background. How my background application can know what the application currently running in the foreground is.
View 4 Replies
View Related
Jun 22, 2010
I want to draw a shape(many circles particularly) into a Specific Bitmap. I have never used canvas / 2D graphs etc. As i see it i create a Drawable put the bitmap in it then "canvas-it" to the shapes i want etc.
View 1 Replies
View Related
Dec 9, 2012
I am trying to build AOSP for my Huawei U8836D, so I am making my own device tree. How do I determine which files in the stock ROM are proprietary, so I can define them in extract-files.sh?
View 1 Replies
View Related
May 8, 2010
Is there a way to determine the audio format of an audio file in Android? On normal java I do it like this:
File file= new File(...);
AudioInputStream stream = AudioSystem.getAudioInputStream(file);
AudioFormat format= stream.getFormat();
View 2 Replies
View Related
Apr 13, 2010
I have a huge UI, in which I have about 300 to 500 rows of data (Horizontal Linear Layout), with each row containing 3 to 4 views. If I load all the UI at once, it takes a long time. How best I can display this UI?
View 5 Replies
View Related
Sep 20, 2010
Helloworld tutorial sample builds and runs just fine, except it doesn't show the text (i.e. loads apps). The only thing I see is that Emulator (Target 2.2 API level 8) comes up with just the "Android" in it. and then the emulator shows up a locked up screen in a while. Here is output from the console [2010-09-20 10:36:55 - HelloAndroid] Android Launch! [2010-09-20 10:36:55 - HelloAndroid] adb is running normally. [2010-09-20 10:36:55 - HelloAndroid] Performing com.example.HelloAndroid.HelloAndroid activity launch [2010-09-20 10:36:55 - HelloAndroid] Automatic Target Mode: Preferred AVD 'my_avd' is not available. Launching new emulator. [2010-09-20 10:37:56 - HelloAndroid] WARNING: Application does not specify an API level requirement! [2010-09-20 10:37:56 - HelloAndroid] Device API version is 8 (Android 2.2) [2010-09-20 10:37:56 - HelloAndroid] HOME is up on device 'emulator-5554' [2010-09-20 10:38:23 - HelloAndroid] Uploading HelloAndroid.apk onto device 'emulator-5554' [2010-09-20 10:38:27 - HelloAndroid] Installing HelloAndroid. apk.After I exit the emulator, I get the following errors. [2010-09-20 09:02:24 - DeviceMonitor] Sending jdwp tracking request failed! [2010-09-20 09:38:46 - ddms]null java.lang.NullPointerException at
com.android.ddmlib.JdwpPacket.writeAndConsume(Jdwp Packet.java:213) at com.android.ddmlib.Client.sendAndConsume(Client.ja va:573) at com.android.ddmlib.HandleHello.sendHELO(HandleHell o.java:142) at com.android.ddmlib.HandleHello.sendHelloCommands(H andleHello.java: 65) at com.android.ddmlib.Client.getJdwpPacket(Client.jav a:670) at com.android.ddmlib.MonitorThread.processClientActi vity(MonitorThread.java:317) at com.android.ddmlib.MonitorThread.run(MonitorThread .java:263)
[2010-09-20 09:38:47 - ddms]null java.lang.NullPointerException at com.android.ddmlib.JdwpPacket.writeAndConsume(Jdwp Packet.java:213) at com.android.ddmlib.Client.sendAndConsume(Client.ja va:573) at com.android.ddmlib.HandleHello.sendHELO(HandleHell o.java:142) at com.android.ddmlib.HandleHello.sendHelloCommands(H andleHello.java: 65) at com.android.ddmlib.Client.getJdwpPacket(Client.jav a:670) at com.android.ddmlib.MonitorThread.processClientActi vity(MonitorThread.java:317) at com.android.ddmlib.MonitorThread.run(MonitorThread .java:263)
[2010-09-20 09:50:11 - DeviceMonitor]Sending jdwp tracking request failed! [2010-09-20 09:59:29 - DeviceMonitor]Sending jdwp tracking request failed! [2010-09-20 09:59:31 - Logcat]device not found com.android.ddmlib.AdbCommandRejectedException: device not found at com.android.ddmlib.AdbHelper.setDevice(AdbHelper.j ava:736) at com.android.ddmlib.AdbHelper.executeRemoteCommand( AdbHelper.java: 373) at com.android.ddmlib.Device.executeShellCommand(Devi ce.java:285) at com.android.ddmuilib.logcat.LogPanel$3.run(LogPane l.java:516)
[2010-09-20 10:40:46 - DeviceMonitor]Sending jdwp tracking request failed!
Also, is there a way to capture the TEXT from CMD window that runs while the Emulator is coming up
View 2 Replies
View Related
Sep 20, 2010
My Helloworld tutorial sample builds and runs just fine, except it doesn't show the text (i.e. loads apps). The only thing I see is that Emulator (Target 2.2 API level 8) comes up with just the "Android" in it. and then the emulator shows up a locked up screen in a while. Here is output from the console
[2010-09-20 10:36:55 - HelloAndroid] Android Launch!
[2010-09-20 10:36:55 - HelloAndroid] adb is running normally.
[2010-09-20 10:36:55 - HelloAndroid] Performing com.example.HelloAndroid.HelloAndroid activity launch
[2010-09-20 10:36:55 - HelloAndroid] Automatic Target Mode: Preferred AVD 'my_avd' is not available. Launching new emulator.
[2010-09-20 10:37:56 - HelloAndroid] WARNING: Application does not specify an API level requirement!
[2010-09-20 10:37:56 - HelloAndroid] Device API version is 8 (Android 2.2)
[2010-09-20 10:37:56 - HelloAndroid] HOME is up on device 'emulator-5554'
[2010-09-20 10:38:23 - HelloAndroid] Uploading HelloAndroid.apk onto device 'emulator-5554'
[2010-09-20 10:38:27 - HelloAndroid] Installing HelloAndroid.apk.
After I exit the emulator, I get the following errors.[2010-09-20 09:02:24 - DeviceMonitor]Sending jdwp tracking request failed![2010-09-20 09:38:46 - ddms]nulljava.lang.NullPointerException
at com.android.ddmlib.JdwpPacket.writeAndConsume(Jdwp Packet.java:213)
at com.android.ddmlib.Client.sendAndConsume(Client.ja va:573)
at com.android.ddmlib.HandleHello.sendHELO(HandleHell o.java:142)
at com.android.ddmlib.HandleHello.sendHelloCommands(H andleHello.java:65)
at com.android.ddmlib.Client.getJdwpPacket(Client.jav a:670)
at com.android.ddmlib.MonitorThread.processClientActi vity(MonitorThread.java:317)
at com.android.ddmlib.MonitorThread.run(MonitorThread .java:263)
[2010-09-20 09:38:47 - ddms]null
java.lang.NullPointerException
at com.android.ddmlib.JdwpPacket.writeAndConsume(Jdwp Packet.java:213)
at com.android.ddmlib.Client.sendAndConsume(Client.ja va:573)
at com.android.ddmlib.HandleHello.sendHELO(HandleHell o.java:142)
at com.android.ddmlib.HandleHello.sendHelloCommands(H andleHello.java:65)
at com.android.ddmlib.Client.getJdwpPacket(Client.jav a:670)
at com.android.ddmlib.MonitorThread.processClientActi vity(MonitorThread.java:317)
at com.android.ddmlib.MonitorThread.run(MonitorThread .java:263)
[2010-09-20 09:50:11 - DeviceMonitor]Sending jdwp tracking request failed!
[2010-09-20 09:59:29 - DeviceMonitor]Sending jdwp tracking request failed!
[2010-09-20 09:59:31 - Logcat]device not found
com.android.ddmlib.AdbCommandRejectedException: device not found
at com.android.ddmlib.AdbHelper.setDevice(AdbHelper.j ava:736)
at com.android.ddmlib.AdbHelper.executeRemoteCommand( AdbHelper.java:373)
at com.android.ddmlib.Device.executeShellCommand(Devi ce.java:285)
at com.android.ddmuilib.logcat.LogPanel$3.run(LogPane l.java:516)
[2010-09-20 10:40:46 - DeviceMonitor]Sending jdwp tracking request failed!
Also, is there a way to capture the TEXT from CMD window that runs while the Emulator is coming up?
View 5 Replies
View Related
Oct 16, 2009
I have an activity that loads and displays images from the SDCard. I create a new AVD, specify the desired image of the sd card (which has all my pictures already loaded), specify that AVD for deployment, and start the application. I noticed a strange behavior. At first, the images are not loaded; the getView method is never called, although the constructor of my adapter is called. If I close the application, and open the Gallery app that comes pre-installed, I see that the sd card folder has the correct number of images, and it 'displays' the first four. If I start my application again, those four images are displayed, and only those. If I go back to the Gallery application, open the sd card folder so that it loads all images, and restart my application, all images are successfully displayed. Any reason why this happens? I am using version 1.6, and (part of) my code is below: Code...
View 2 Replies
View Related
Jul 27, 2010
How do I figure out, if an app is loaded for the first time after it has been downloaded. I mean when the app is first bought/downloaded from market, how will I figure it that this is the first time(never has been run on this phone) this is going to run hence I can throw up some registration activity?
View 6 Replies
View Related