Strange Behavior of Android VideoView - "Can't Play Video" - android

In my application,showing video from sdcard folder or new taken video from Video intent in a VideoView in different Activity by passing file path of the video selected.
Now the problem is,
I have tested this app in my 2 devices LG Optimus Black and LG Optimus Me and it works like charm not problem no force close.
Now when i test this app in Samsung Fascinate 2.1 the video view shows the message "Can't Play Video" no matter i select existing video or take new one.
Remember the app is working fine with the above 2 devices.
In the ShowVideo activity i have button to upload the video, when i got the message "Can't Play Video" i been able to take video from the same path and upload it and can check that video at server side but video view didn't played that video.
So, the Video Path of the SDCard is not the problem thats for sure.
also the Video are of .3gp or .mp4 format only so the format is also supported by android
.
My Questions Are :
1)When the message "Can't Play Video" occurs?
2)What are the Solution for that?
and 3) What could be possible mistakes in my application?
here is the logcat output while i got that message but don't see any error/exception in that.
I/ActivityManager( 2227): Starting activity: Intent { cmp=com.zoodigapp.zoodig/com.zoodigapp.media.ShowVideo (has extras) }
V/SettingsProvider( 2227): system <- value=1.0 name=font_scale
V/SettingsProvider( 2227): property: sys.settings_system_version=26
V/SettingsProvider( 2227): notifying: content://settings/system/font_scale
D/HardwareService( 2227): Brightness NATIVE setBacklightBrightness running. light: 2bightness ==> 30 mode: 1
D/NetworkLocationProvider( 2227): onDataConnectionStateChanged 6
D/MobileDataStateTracker( 2227): default Received state= CONNECTING, old= CONNECTING, reason= (unspecified), apnTypeList= *
D/AGPSManagerService( 2227): state: CONNECTING apnName: Verizon reason: null
D/dalvikvm( 3326): GC freed 2472 objects / 140504 bytes in 73ms
I/File ( 3326): /sdcard/DCIM/Camera/video-2011-10-17-10-40-54.mp4
V/MediaStore( 3326): We probably run out of space, so create the thumbnail in memory.
I/MediaPlayerService( 2182): Use PV_PLAYER for url:/sdcard/DCIM/Camera/video-2011-10-17-10-40-54.mp4
E/MetadataDriver( 2182): MetadataDriver::setDataSource url file type is isAudiofile(0)
D/ ( 2182): SISO TEST registering PVMFRecognizerPluginFactory
D/ ( 2182): SISO TEST registering PVMFRecognizerPluginFactory success
E/MetadataDriver( 2182): isCommandSuccessful: Command id(0 and expected 0) and status (-17 and expected 1), data corruption (false) at state (4).
E/MetadataDriver( 2182): isCommandSuccessful: Command id(1 and expected 1) and status (-14 and expected 1), data corruption (false) at state (5).
E/MetadataDriver( 2182): captureFrame : time = 0
E/MetadataDriver( 2182): captureFrame : inputWidth = 0, inputHeight =0, bAspectratio=0, bResize=0
D/MediaUploader( 2492): UploadsQueue.getAllPending: elapsed msec=449
I/MediaUploader( 2492): UploadManager.uploadPendingItems: Found 1 items in queue.
I/Selected( 3326): =============Second
D/MediaUploader( 2492): isGphotosSynced: FALSE -- starting gphotos update refresh for -5709461173740324808
W/IInputConnectionWrapper( 3505): showStatusIcon on inactive InputConnection
I/copybit ( 2227): [createPP] fimc version : 50
I/MediaPlayerService( 2182): Use PV_PLAYER for url:/DCIM/Camera/video-2011-10-17-10-40-54.mp4
D/ ( 2182): SISO TEST registering PVMFRecognizerPluginFactory
D/ ( 2182): SISO TEST registering PVMFRecognizerPluginFactory success
D/ ( 2182): SISO TEST PVOMA1FFRecognizerFactory::CreateRecognizerPlugin()
D/ ( 2182): SISO TEST PVOMA1FFRecognizerFactory::CreateRecognizerPlugin() plugin found
D/ ( 2182): SISO TEST PVOMA1FFRecognizerFactory::DestroyRecognizerPlugin()
E/OsclDirectFileIO( 2182): [LargeFileSupport] OsclDirectFileIO::OpenFileOrSharedFd Error = -1
W/MediaPlayer( 3326): info/warning (1, 26)
E/PlayerDriver( 2182): Command PLAYER_SET_DATA_SOURCE completed with an error or info -4
E/MediaPlayer( 3326): SISO TEST MEDIA_ERROR
E/MediaPlayer( 3326): error (-4, -4)
W/PlayerDriver( 2182): PVMFInfoErrorHandlingComplete
V/MediaProvider( 2349): stopThumbWorkerSuspendTimer
V/MediaProvider( 2349): Resuming ThumbWorker
W/MediaProvider( 2349): Have message but no request?
I/System.out( 2647): interface name: null
I/MediaPlayer( 3326): Info (1,26)
E/MediaPlayer( 3326): Error (-4,-4)
D/VideoView( 3326): Error: -4,-4
D/MediaUploader( 2492): UploadManager.uploadPendingItems: Waiting for GPhotos sync
D/MediaUploader( 2492): UploadsQueue.getAllPending: elapsed msec=5
I/MediaUploader( 2492): UploadManager.uploadPendingItems: Found 1 items in queue.
I/POWER_OFF_TEST( 2227): mBatteryLevel = 38 mBatteryDecimalPoint = 1
D/MediaUploader( 2492): UploadsAsyncQueryHandler.notifiyDatabaseChangeListeners
D/MediaUploader( 2492): isGphotosSynced: FALSE -- update is in progress for -5709461173740324808
D/MediaUploader( 2492): UploadManager.uploadPendingItems: Waiting for GPhotos sync
D/MediaUploader( 2492): updateQueueState: RUNNING
I/GooglePlusOne( 2492): Starting new CAMERA_SYNC_CREATED request 1
I/ActivityManager( 2227): Displayed activity com.zoodigapp.zoodig/com.zoodigapp.media.ShowVideo: 1251 ms (total 1251 ms)
V/InputDevice( 2227): ID[0]=0 Dn (0=>1)
V/WindowManager( 2227): Dsptch >Window{47a67278 com.zoodigapp.zoodig/com.zoodigapp.media.ShowVideo paused=false}
D/dalvikvm( 2227): GC freed 4009 objects / 210024 bytes in 155ms
V/InputDevice( 2227): ID[0]=0 Up (1=>0)
V/WindowManager( 2227): Dsptch >Window{47a67278 com.zoodigapp.zoodig/com.zoodigapp.media.ShowVideo paused=false}
W/InputManagerService( 2227): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#47d89250
D/dalvikvm( 2492): GC freed 11952 objects / 682568 bytes in 171ms
D/dalvikvm( 2647): GC freed 7435 objects / 656456 bytes in 26ms
D/dalvikvm( 2647): GC freed 3079 objects / 498304 bytes in 60ms
I/System.out( 2647): interface name: null
I/GooglePlusOne( 2492): CAMERA_SYNC_CREATED request 1 completed with code=200
D/MediaUploader( 2492): onGphotosChange: sawError=false; errs=0; retry=Wed Dec 31 17:00:00 America/Boise 1969; expiry=Mon Oct 17 10:56:20 America/Boise 2011
D/MediaUploader( 2492): UploadsQueue.getAllPending: elapsed msec=17
I/MediaUploader( 2492): UploadManager.uploadPendingItems: Found 1 items in queue.
D/MediaUploader( 2492): isGphotosSynced: TRUE for -5709461173740324808
D/MediaUploader( 2492): existsInGphotos: false info=name=video-2011-10-17-10-40-54.mp4 fileUri=content://media/external/video/media/37 fileSize=2477915;
D/MediaUploader( 2492): UploadManager.uploadPendingItems: starting upload...
D/MediaUploader( 2492): UploadManager.upload: info=name=video-2011-10-17-10-40-54.mp4 fileUri=content://media/external/video/media/37 fileSize=2477915
I/NetworkStat( 2678): Network type: MOBILE
I/NetworkStat( 2678): -------- mobile data network is NOT available as of now
D/NotificationService( 2227): enqueueNotification :: notification.defaults = 0, Notification.DEFAULT_SOUND = 1, notification.sound = null
D/dalvikvm( 2492): GC freed 4032 objects / 238248 bytes in 49ms
I/dalvikvm-heap( 2492): Grow heap (frag case) to 6.708MB for 524304-byte allocation
D/dalvikvm( 2492): GC freed 291 objects / 13392 bytes in 58ms
D/MediaUploader( 2492): UploadsAsyncQueryHandler.notifiyDatabaseChangeListeners
D/MediaUploader( 2492): GlsAuthorizer.getAuthToken: authTokenType=lh2; account=dprichards#gmail.com;
D/MediaUploader( 2492): executeWithAuthRetry: starting httpClient.execute #1
D/dalvikvm( 2870): GC freed 555 objects / 24144 bytes in 269ms
I/System.out( 2492): interface name: null
V/InputDevice( 2227): ID[0]=0 Dn (0=>1)
V/WindowManager( 2227): Dsptch >Window{47cf6308 com.zoodigapp.zoodig/com.zoodigapp.media.ShowVideo paused=false}
V/InputDevice( 2227): ID[0]=0 Up (1=>0)
V/WindowManager( 2227): Dsptch >Window{47cf6308 com.zoodigapp.zoodig/com.zoodigapp.media.ShowVideo paused=false}
D/dalvikvm( 2647): GC freed 7301 objects / 659064 bytes in 78ms
I/System.out( 2647): interface name: null
I/System.out( 2647): interface name: null
I/System.out( 2647): interface name: null
D/dalvikvm( 2647): GC freed 2654 objects / 324016 bytes in 149ms
I/System.out( 2647): interface name: null
D/MediaUploader( 2492): getStatusCode: status=HTTP/1.1 200 OK
D/MediaUploader( 2492): getStatusCode: status=HTTP/1.1 200 OK
D/MediaUploader( 2492): UPLOAD_START: uploadUrl=https://picasaweb.google.com/data/upload/resumable/media/create-session/feed/api/user/default/albumid/camera-sync?xmlerrors=1&upload_id=AEnB2Uqe2bdvyx5p31Ta-sS4ytggj07_6-uiKG_hCOc6sT1u8eqhvr-8oZdUT1uPHxuAxXphUiJXyq-i_8YaJlT2YLholp__Sw
D/MediaUploader( 2492): UploadManager.onProgress
V/MediaUploader( 2492): UploadManager.progressUpdate: guid=1351689615505998240; bytes=0
D/dalvikvm( 2647): GC freed 920 objects / 202544 bytes in 53ms
D/dalvikvm( 2492): GC freed 7362 objects / 498448 bytes in 73ms
D/MediaUploader( 2492): UploadsAsyncQueryHandler.notifiyDatabaseChangeListeners
D/dalvikvm( 2492): GC freed 658 objects / 129232 bytes in 42ms
I/dalvikvm-heap( 2492): Grow heap (frag case) to 7.250MB for 262160-byte allocation
D/dalvikvm( 2492): GC freed 0 objects / 0 bytes in 41ms
D/dalvikvm( 2492): GC freed 92 objects / 135128 bytes in 30ms
I/dalvikvm-heap( 2492): Grow heap (frag case) to 7.621MB for 524304-byte allocation
D/dalvikvm( 2492): GC freed 0 objects / 0 bytes in 44ms
D/MediaUploader( 2492): executeWithAuthRetry: starting httpClient.execute #1
D/dalvikvm( 2647): GC freed 576 objects / 53240 bytes in 182ms
V/InputDevice( 2227): ID[0]=0 Dn (0=>1)
V/WindowManager( 2227): Dsptch >Window{47cf6308 com.zoodigapp.zoodig/com.zoodigapp.media.ShowVideo paused=false}
V/InputDevice( 2227): ID[0]=0 Up (1=>0)
V/WindowManager( 2227): Dsptch >Window{47cf6308 com.zoodigapp.zoodig/com.zoodigapp.media.ShowVideo paused=false}
I/ActivityManager( 2227): Starting activity: Intent { cmp=com.zoodigapp.zoodig/.WriteMessage (has extras) }
If you find anything not described well please comment below.
Additional details (moved from comments):
They are merely of 1 minutes and the last one I tested and failed on Samsung that was of only 20 seconds. and sizes are mostly in MB not more than 20 MB right now.
The video is taken from the same device and immediately after taking that video I try to show in my activity same way other already stored video are also fine...actually after uploading that video I can see that video and can download also

1)When the message "Can't Play Video" occurs?
Android usually gives out this message, when it is not able to play the media content. The reasons for this to happen can be anything like
Unsupported file format
Unsupported codecs
Erroneous content
to mention a few.
2)What are the Solution for that?
Unless you have your own Media Framework in your app, there is no solution from the application level
3) What could be possible mistakes in my application?
Very unlikely the mistake is in your application. If you read the logs, you will see that the error seems to originate from the DataSource of opencore (Which version of android are you running anyway? It is still using Opencore instead of StageFright). It is recognizing it as a large file (> 2GB) and hence giving out the error "E/OsclDirectFileIO( 2182): [LargeFileSupport] OsclDirectFileIO::OpenFileOrSharedFd Error = -1"
The other thing to note is certain phones have better multimedia capability than the other phones, since OEM's can themselves improve the multimedia capability. So there is no written guarantee that all files can be played on all devices, even though it conforms to the supported formats, codecs mentioned by Android.

Its all about format problem, Some phone record the video in mp4 format and some in 3gp format, but in almost all phones the default mediaplayer support 3gp format. So the solution is you need to convert it into 3gp at the time of playing. This thing is difficult to handle in android, So at server end you can do it easily and hence whatever the format of the video is being uploaded you can download it in one format .3gp and it will work fine.

Make sure that your video is in MP4 format , but if still does not play or shows same error then fault is not with the code. Fault is in the video resolution. just check height and width of you video and match it with you video view component. There are lot of free video compressors Online available. So just compress your video and test it.
It will work.
Cheers!!!

I kept getting the same "Can't Play Video" message while trying to play video from the phone itself. First I didn't input good path to a file but there was anther interesting issue.
I've type path from the root, example /videoFileName.mp4 and I should have type it with sdcard in between like /sdcard/videoFileName.mp4
My Sony Ercisson Xperia Arc was connected as a usb mass device storage at the same time I was running my app through adb, so internal sd card was unmounted and file could not be found. I've discovered this when I tryed same code on Samsung Galaxy S which behaves differently when connected.

If you have mp4 file having H.264 baseline encoding and still you are unable to play video in your android device then it might be problem in .htAccess file on server side. It might be zipping .mp4 file. few devices are able to play video by unzipping it and stream it but not in all device cases. You need to change .htAccess file on server side. Change in output filter and include file format .mp4 to exclude it from being zip at streaming time.
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|swf|mp4)$ \ no-gzip dont-vary

Google recently open-sourced Exoplayer after Google IO 2014.
My experience with video playing with it was good so far.
https://github.com/google/ExoPlayer
I could stream videos from Dropbox/AWS
Stream videos from youtube.
Things still depend upon codecs supported by the device.

I had this same issue while using VideoView, while i tried to check all things regarding the video the issue was in the AndroidManifest.xml File, It was regarding the permission to use EXTERNAL STORAGE give it a shot it might solve the issue.

I came across the same problem and what worked for is adding the Internet permission to the manifest file since I am getting video from url.
<uses-permission android:name="android.permission.INTERNET"/>
This is how I am populating listview of videos.
//assign video
mVideosListView = (ListView) findViewById(R.id.videoListView);
//create videos
Video riverVideo = new Video("https://s3.amazonaws.com/androidvideostutorial/862009639.mp4");
Video carsVideo = new Video("https://s3.amazonaws.com/androidvideostutorial/862013714.mp4");
Video townVideo = new Video("https://s3.amazonaws.com/androidvideostutorial/862014159.mp4");
Video whiteCarVideo = new Video("https://s3.amazonaws.com/androidvideostutorial/862014159.mp4");
Video parkVideo = new Video("https://s3.amazonaws.com/androidvideostutorial/862014834.mp4");
Video busyCityVideo = new Video("https://s3.amazonaws.com/androidvideostutorial/862017385.mp4");
mVideosList.add(riverVideo);
mVideosList.add(carsVideo);
mVideosList.add(townVideo);
mVideosList.add(whiteCarVideo);
mVideosList.add(parkVideo);
mVideosList.add(busyCityVideo);
/***populate video list to adapter**/
mVideoAdapter = new VideoAdapter(this, mVideosList);
mVideosListView.setAdapter(mVideoAdapter);

I faced the same issue once. In My case only issue was fie format. i Just changed the video format to .mp4 and it works like charm on all the devices and emulator i used.
my suggestion is to check your video format first and then try other solutions.

For me was a problem with the codec used by video.
I installed the Any Video Converter and converted the video using the settings for Google Android (x264).
Now I can play on every device.

My problem was I had saved it in .avi format instead of .m4v format, and it worked liked a charm on my Samsung...thanks for everyone's help!

Related

other packages also run on my android app

I have to run my android application which means am getting the following messages on my logcat window:
12:05:36.056: System_process I/ActivityManager(59): Displayed activity com.xmlparsing/.MainActivity: 581 ms (total 581 ms)
12:05:41.136: com.android.defcon D/dalvikvm(253): GC_EXPLICIT freed 152 objects / 11024 bytes in 60ms
12:05:46.126: com.svox.pico D/dalvikvm(264): GC_EXPLICIT freed 31 objects / 1512 bytes in 50ms
12:05:51.156: com.android.setting D/dalvikvm(125): GC_EXPLICIT freed 975 objects / 42392 bytes in 78ms
12:06:40.666: com.xmlparsing D/dalvikvm(1131): GC_FOR_MALLOC freed 3884 objects / 321368 bytes in 50ms
12:06:40.836: com.xmlparsing D/dalvikvm(1131): GC_FOR_MALLOC freed 3654 objects / 427296 bytes in 48ms
12:06:41.026: com.xmlparsing D/dalvikvm(1131): GC_FOR_MALLOC freed 4007 objects / 418288 bytes in 45ms
12:06:41.245: com.xmlparsing D/dalvikvm(1131): GC_FOR_MALLOC freed 4516 objects / 414608 bytes in 54ms
12:06:41.456: com.xmlparsing D/dalvikvm(1131): GC_FOR_MALLOC freed 4194 objects / 399504 bytes in 53ms
12:06:41.616: com.xmlparsing D/dalvikvm(1131): GC_FOR_MALLOC freed 3365 objects / 412104 bytes in 43ms
12:06:41.666: com.xmlparsing I/System.out(1131): category size6
12:06:41.666: com.xmlparsing I/System.out(1131): category name is---------------->Photos
Here my application package is com.xmlparsing.
But here other packages(com.android.defcon,com.svox.pico,com.android.settings) is running on starting.this packages only taking more time to reading(loading) the data.please check the time.my xml file is read within second.why that package is loading.how can i control it.please give me solution for these
Those packages are not running "on your app". Android supports multitasking, so it is possible to have more than one app alive at a time.
In any case, the LogCat you posted shows that it is simply a GC call, which means Android is trying to free up memory. There is nothing you can do to control this.
If you want to view LogCay messages from only your app, try filtering by process id.
What you're seeing are log messages from the different processes that are going through Garbage Collection (GC).
On any system, Android or otherwise, there will likely be multiple processes running at the same time. On Android, the processes will periodically go through Garbage Collection to free up memory and keep the system running well and within its constrained resources. This is expected behavior.

App takes too long to start-up

I have and android app which takes >=5 seconds to show up after it's icon is clicked.
As soon as I click the icon, I get the black screen with name of the app in status bar. After 5+ seconds, the home screen appears.
I referred this post on SO which and I got following result from stack trace
16:13:14.915: I/ActivityManager(59): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=packageName/.SelectType }
16:13:14.954: I/SurfaceFlinger(59):
16:13:14.954: I/SurfaceFlinger(59): SurfaceFlinger::createSurface() : layer->mIdentity=176, LayerName= Starting packageName
16:13:14.954: I/SurfaceFlinger(59): SurfaceFlinger::createSurface() : layer->clientIndex=2, surfaceHandle->mToken=0x2
16:13:16.026: D/AnrParser(184): Waiting kernel log . . .
16:13:16.614: D/dalvikvm(6890): GC_FOR_MALLOC freed 12274 objects / 785016 bytes in 135ms
16:13:17.784: D/dalvikvm(133): GC_EXTERNAL_ALLOC freed 415 objects / 21624 bytes in 1285ms
16:13:17.914: D/dalvikvm(6890): GC_FOR_MALLOC freed 5762 objects / 339024 bytes in 90ms
16:13:18.174: D/AnrParser(184): Waiting kernel log . . .
16:13:18.344: E/keystore(6966): chdir: /data/misc/keystore: Permission denied
16:13:19.693: D/dalvikvm(6890): GC_FOR_MALLOC freed 5994 objects / 372624 bytes in 93ms
16:13:20.173: D/AnrParser(184): Waiting kernel log . . .
16:13:22.173: D/AnrParser(184): Waiting kernel log . . .
16:13:22.743: I/SurfaceFlinger(59):
16:13:22.743: I/SurfaceFlinger(59): SurfaceFlinger::createSurface() : layer->mIdentity=177, LayerName= packageName/packageName.SelectType
16:13:22.743: I/SurfaceFlinger(59): SurfaceFlinger::createSurface() : layer->clientIndex=0, surfaceHandle->mToken=0x0
16:13:22.983: D/dalvikvm(6890): GC_FOR_MALLOC freed 21467 objects / 1097728 bytes in 119ms
16:13:23.403: E/keystore(6973): chdir: /data/misc/keystore: Permission denied
16:13:24.173: D/AnrParser(184): Waiting kernel log . . .
16:13:24.923: W/ActivityManager(59): Launch timeout has expired, giving up wake lock!
16:13:25.264: W/ActivityManager(59): Activity idle timeout for HistoryRecord{47f56388 packageName/.SelectType}
16:13:25.403: I/ActivityManager(59): Displayed activity packageName/.SelectType: 10206 ms (total 10206 ms)
As you can see in above log, 1st statement is 16:13:14.915: I/ActivityManager(59): Starting activity and last one is 16:13:25.403: I/ActivityManager(59): Displayed activity.
So there is a gap of approx. 10 to 11 seconds.
Any help appreciated.
You might be executing something heavy on the onCreate() or onResume() of the activity...try to debug it to see if you are performing database or I/O operations in these methods directly. You can also activate the StrictMode for a better overview of what is slowing your app down.
In my case, this happens when I use the custom theme in the application tag and with app launcher Activity in Manifest File
Such that i use this custom theme
android:theme="#style/Theme.MyAppTheme"
But when I remove the theme from the application tag and change the app launcher Activity theme to the default theme my problem is Solve
I Change the app launcher Activity theme with
android:theme="#style/Theme.AppCompat.Light.NoActionBar"

Jelly Bean starts googlequicksearchbox when pressing back button

I am developing an application and on Motorola XOOM with Android 4.1 it starts Google Search activity when I am pressing back button on video player activity in my application. No intents for Google search have been sent from this application. Also it works properly on previous android versions even ICS devices. Here is the logs
09-05 14:19:53.260: I/InputReader(271): Reconfiguring input devices.changes=0x00000004
09-05 14:19:53.260: I/InputReader(271): Device reconfigured: id=2, name='qtouch-touchscreen', surface size is now 1280x800, mode is 1
09-05 14:19:53.360: I/ActivityManager(271): Config changed: {1.0 0mcc0mnc en_US sw800dp w800dp h1232dp xlrg port finger -keyb/v/h -nav/h s.37}
09-05 14:19:53.410: D/myTag(11672): com.orvis.container.OKnot#41b7f650
09-05 14:19:53.440: D/dalvikvm(1231): GC_CONCURRENT freed 248K, 5% free 7967K/8327K, paused 9ms+6ms, total 70ms
09-05 14:19:53.460: W/AudioFlinger(93): session id 764 not found for pid 11672
09-05 14:19:53.510: I/ActivityManager(271): START {act=android.intent.action.ASSIST flg=0x10000000 cmp=com.google.android.googlequicksearchbox/.SearchActivity u=0} from pid 344
Please assist.
Thank you.

android service not working when app enters background in titanium

Hi I try to develop a simple Android service application using Titanium by following their tutorial. It works well when the application is in foreground, but when I press back button it kills the app and my service is not running.
Below is the code I used and the log I got when the app enters background. Please let me know where I am going wrong. (I am using Titanium SDK 2.0.1.GA2 and Android SDK 2.2 with Android Runtime v8/Rhino].
My app.js file:
var intent = Titanium.Android.createServiceIntent( { url: 'logservice.js' } );
// Service should run its code every 10 seconds.
intent.putExtra('interval', 10000);
// A message that the service should 'echo'
intent.putExtra('message_to_echo', 'Titanium rocks!');
var service = Titanium.Android.createService(intent);
service.addEventListener('resume', function(e) {
Titanium.API.info('Service code resumes, iteration ' + e.iteration);
});
service.addEventListener('pause', function(e) {
Titanium.API.info('Service code pauses, iteration ' + e.iteration);
/* if (e.iteration === 3) {
Titanium.API.info('Service code has run 3 times, will now stop it.');
service.stop();
} */
});
service.start();
And my logservice.js file is:
var service = Titanium.Android.currentService;
var intent = service.intent;
var message = intent.getStringExtra("message_to_echo");
Titanium.API.info("Hello World! I am a Service. I have this to say: " + message);
I included that service tag in tiapp.xml
And this is the log I am getting when I press back button:
W/KeyCharacterMap( 322): No keyboard for id 0
W/KeyCharacterMap( 322): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
E/TiBaseActivity( 322): (main) [62040,92891] Layout cleanup.
D/dalvikvm( 322): GC_FOR_MALLOC freed 9526 objects / 480272 bytes in 115ms
D/dalvikvm( 322): GC_FOR_MALLOC freed 12770 objects / 693152 bytes in 80ms
D/dalvikvm( 322): GC_FOR_MALLOC freed 8846 objects / 508872 bytes in 77ms
D/dalvikvm( 322): GC_FOR_MALLOC freed 8976 objects / 512112 bytes in 78ms
D/EventEmitter( 322): callHandler function not available for resume
W/TiAnalyticsSvc( 322): (Thread-15) [29966,122857] Analytics Service Started
I/TiAnalyticsSvc( 322): (Thread-15) [69,122926] Sending 1 analytics events.
D/dalvikvm( 322): GC_FOR_MALLOC freed 7386 objects / 436936 bytes in 87ms
D/NativeCrypto( 322): Freeing OpenSSL session
D/dalvikvm( 322): GC_FOR_MALLOC freed 1581 objects / 89648 bytes in 71ms
I/dalvikvm-heap( 322): Grow heap (frag case) to 3.588MB for 87396-byte allocation
D/dalvikvm( 322): GC_FOR_MALLOC freed 12 objects / 712 bytes in 76ms
D/dalvikvm( 322): GC_FOR_MALLOC freed 956 objects / 49400 bytes in 88ms
I/dalvikvm-heap( 322): Grow heap (frag case) to 3.624MB for 87396-byte allocation
D/dalvikvm( 322): GC_FOR_MALLOC freed 0 objects / 0 bytes in 75ms
W/TiAnalyticsSvc( 322): (Thread-15) [3772,126698] Stopping Analytics Service
D/SntpClient( 60): request time failed: java.net.SocketException: Address family not supported by protocol

How to find the origin of a GC_FOR_MALLOC?

I'm working on an android app which fall into an infinite loop of GC_FOR_MALLOC freed :
06-15 11:24:56.685: DEBUG/dalvikvm(118): GC_FOR_MALLOC freed 4136 objects / 374744 bytes in 66ms
06-15 11:24:59.176: DEBUG/dalvikvm(521): GC_FOR_MALLOC freed 9340 objects / 524152 bytes in 645ms
06-15 11:24:59.846: DEBUG/dalvikvm(521): GC_FOR_MALLOC freed 9344 objects / 524328 bytes in 149ms
06-15 11:25:01.535: DEBUG/dalvikvm(521): GC_FOR_MALLOC freed 9346 objects / 524448 bytes in 193ms
06-15 11:25:02.175: DEBUG/dalvikvm(521): GC_FOR_MALLOC freed 9344 objects / 524344 bytes in 126ms
The application read some jpeg image over a socket (dedicated thread) and display it in a imageView. The GC loop is bloking the image display.
Is there a solution to know what line or at least what part of the code is throwing the Garbage collection ?
Thanks
I'm not sure if you can access the VM and check why it is performing gc all the time, but gc is usually performed when there is a need for it. You should check what is using so much memory. It may be loading your image (is it a big image?) or perhaps it is something else in your app. Check this post on how to analyse your memory usage and while you are at it check for memory leaks.

Categories

Resources