android audiomanager bug? - android

i'm trying to load a shoutcast live stream into audiomanager but i have a problem, it works fine on wildfire 2.2 oficial, wildfire 2.3 rooted, emulator w/ 2.2 and not works on optimus black 2.2 oficial and x10 mini pro 2.1 oficial. Is this a bug of mediaplayer or what?
code is simple:
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource("http://150.214.174.129:8000/");
mediaPlayer.prepare();
mediaPlayer.start();
logcat when not working:
03-18 00:28:05.371: W/AudioSystem(3345): AudioFlinger server died!
03-18 00:28:05.371: W/IMediaDeathNotifier(3345): media server died
03-18 00:28:05.371: E/MediaPlayer(3345): error (100, 0)
03-18 00:28:05.379: W/System.err(3345): java.io.IOException: Prepare failed.: status=0x64
03-18 00:28:05.379: W/System.err(3345): at android.media.MediaPlayer.prepare(Native Method)
03-18 00:28:05.379: W/System.err(3345): at es.radio.onCreate(pruebaradio.java:77)
03-18 00:28:05.379: W/System.err(3345): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-18 00:28:05.379: W/System.err(3345): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-18 00:28:05.379: W/System.err(3345): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-18 00:28:05.379: W/System.err(3345): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-18 00:28:05.379: W/System.err(3345): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-18 00:28:05.379: W/System.err(3345): at android.os.Handler.dispatchMessage(Handler.java:99)
03-18 00:28:05.379: W/System.err(3345): at android.os.Looper.loop(Looper.java:123)
03-18 00:28:05.379: W/System.err(3345): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-18 00:28:05.379: W/System.err(3345): at java.lang.reflect.Method.invokeNative(Native Method)
03-18 00:28:05.379: W/System.err(3345): at java.lang.reflect.Method.invoke(Method.java:521)
03-18 00:28:05.379: W/System.err(3345): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
03-18 00:28:05.379: W/System.err(3345): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
03-18 00:28:05.379: W/System.err(3345): at dalvik.system.NativeStart.main(Native Method)
03-18 00:28:05.379: E/MediaPlayer(3345): start called in state 0
03-18 00:28:05.379: E/MediaPlayer(3345): error (-38, 0)
03-18 00:28:05.402: E/MediaPlayerJAVA(3345): Error (-38,0)
03-18 00:28:05.402: D/MediaPlayerJAVA(3345): Info (-38,0)

You could try if that's any better but I guess it's related to the hardware that is just unable to play the filetype
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource("http://150.214.174.129:8000/");
mediaPlayer.prepareAsync();
mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
mp.start();
}
});

Related

how to check Environment.DIRECTORY_DOCUMENTS is null in android

I'm trying to run a check as if (Environment.DIRECTORY_DOCUMENTS == null) however when I do get to this line, I get a null pointer exception. Now I know that there is no Documents Directory on the device I'm testing, so it should give me a null value and move into the block of code, but I want it to actually check it. I just gives an error.
My logcat shows:
03-18 11:11:24.667: E/AndroidRuntime(5183): FATAL EXCEPTION: main
03-18 11:11:24.667: E/AndroidRuntime(5183): java.lang.NoSuchFieldError: android.os.Environment.DIRECTORY_DOCUMENTS
03-18 11:11:24.667: E/AndroidRuntime(5183): at com.example.testapp.MainActivity$3.onClick(MainActivity.java:640)
03-18 11:11:24.667: E/AndroidRuntime(5183): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:168)
03-18 11:11:24.667: E/AndroidRuntime(5183): at android.os.Handler.dispatchMessage(Handler.java:99)
03-18 11:11:24.667: E/AndroidRuntime(5183): at android.os.Looper.loop(Looper.java:137)
03-18 11:11:24.667: E/AndroidRuntime(5183): at android.app.ActivityThread.main(ActivityThread.java:4514)
03-18 11:11:24.667: E/AndroidRuntime(5183): at java.lang.reflect.Method.invokeNative(Native Method)
03-18 11:11:24.667: E/AndroidRuntime(5183): at java.lang.reflect.Method.invoke(Method.java:511)
03-18 11:11:24.667: E/AndroidRuntime(5183): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
03-18 11:11:24.667: E/AndroidRuntime(5183): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
03-18 11:11:24.667: E/AndroidRuntime(5183): at dalvik.system.NativeStart.main(Native Method)
How do I check (programmatically) if there is a documents directory on my device?
Environment.DIRECTORY_DOCUMENTS field is added in API Level 19.
So you can change the code as below to support for different versions:
File currentDir = null;
if (Build.VERSION.SDK_INT >= 19) {
currentDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS));
}else{
currentDir = new File(Environment.getExternalStorageDirectory() + "/Documents");
}
As see here Environment.DIRECTORY_DOCUMENTS field is added in API Level 19 (Android 4.4(KITKAT))
Make sure using API 19 for project and in AndroidManifest.xml

Google Maps API v2 Android not working on Nexus 5 (Android 4.4.2)?

I'm developing an app with Google Maps API v2, I've tested it and it is pretty working on HTC Desire 500, Samsung Galaxy SIII mini and Mediacom Phonepad. But on Nexus 5 (with Android Kitkat 4.4.2) my app crashes when I click the button that opens the "ActivityMap".
I've also installed the API 19 of Android. Anyone can help me? Every kind of help will be greatly appreciated. If you need my code, just ask me.
03-18 11:21:37.240: E/AndroidRuntime(18406): FATAL EXCEPTION: main
03-18 11:21:37.240: E/AndroidRuntime(18406): Process: com.example.myapplication, PID: 18406
03-18 11:21:37.240: E/AndroidRuntime(18406): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MapActivity}: java.lang.NullPointerException
03-18 11:21:37.240: E/AndroidRuntime(18406): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
03-18 11:21:37.240: E/AndroidRuntime(18406): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
03-18 11:21:37.240: E/AndroidRuntime(18406): at android.app.ActivityThread.access$800(ActivityThread.java:135)
03-18 11:21:37.240: E/AndroidRuntime(18406): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-18 11:21:37.240: E/AndroidRuntime(18406): at android.os.Handler.dispatchMessage(Handler.java:102)
03-18 11:21:37.240: E/AndroidRuntime(18406): at android.os.Looper.loop(Looper.java:136)
03-18 11:21:37.240: E/AndroidRuntime(18406): at android.app.ActivityThread.main(ActivityThread.java:5017)
03-18 11:21:37.240: E/AndroidRuntime(18406): at java.lang.reflect.Method.invokeNative(Native Method)
03-18 11:21:37.240: E/AndroidRuntime(18406): at java.lang.reflect.Method.invoke(Method.java:515)
03-18 11:21:37.240: E/AndroidRuntime(18406): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-18 11:21:37.240: E/AndroidRuntime(18406): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-18 11:21:37.240: E/AndroidRuntime(18406): at dalvik.system.NativeStart.main(Native Method)
03-18 11:21:37.240: E/AndroidRuntime(18406): Caused by: java.lang.NullPointerException
03-18 11:21:37.240: E/AndroidRuntime(18406): at com.example.myapplication.MapActivity.onCreate(MapActivity.java:53)
03-18 11:21:37.240: E/AndroidRuntime(18406): at android.app.Activity.performCreate(Activity.java:5231)
03-18 11:21:37.240: E/AndroidRuntime(18406): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-18 11:21:37.240: E/AndroidRuntime(18406): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
03-18 11:21:37.240: E/AndroidRuntime(18406): ... 11 more

Can any one tell what this logcat is saying?

Here i am trying to consume one web service.And i am trying to show json data from that web service into listview in android? But i am getting errors on my logcat like below
Logcat
03-18 18:11:51.830: I/System.out(296): Transparent 17170445
03-18 18:11:51.990: W/System.err(296): java.net.SocketException: Permission denied
03-18 18:11:52.000: W/System.err(296): at org.apache.harmony.luni.platform.OSNetworkSystem.createStreamSocketImpl(Native Method)
03-18 18:11:52.000: W/System.err(296): at org.apache.harmony.luni.platform.OSNetworkSystem.createStreamSocket(OSNetworkSystem.java:186)
03-18 18:11:52.000: W/System.err(296): at org.apache.harmony.luni.net.PlainSocketImpl.create(PlainSocketImpl.java:265)
03-18 18:11:52.000: W/System.err(296): at java.net.Socket.checkClosedAndCreate(Socket.java:873)
03-18 18:11:52.010: W/System.err(296): at java.net.Socket.connect(Socket.java:1020)
03-18 18:11:52.010: W/System.err(296): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:62)
03-18 18:11:52.010: W/System.err(296): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:88)
03-18 18:11:52.010: W/System.err(296): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHTTPConnection(HttpURLConnectionImpl.java:927)
03-18 18:11:52.010: W/System.err(296): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:909)
03-18 18:11:52.010: W/System.err(296): at org.ksoap2.transport.ServiceConnectionSE.connect(ServiceConnectionSE.java:76)
03-18 18:11:52.010: W/System.err(296): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:146)
03-18 18:11:52.010: W/System.err(296): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:95)
03-18 18:11:52.010: W/System.err(296): at com.example.png.StationsListActivity.callService(StationsListActivity.java:97)
03-18 18:11:52.010: W/System.err(296): at com.example.png.StationsListActivity$3.run(StationsListActivity.java:78)
03-18 18:11:52.429: D/AndroidRuntime(296): Shutting down VM
03-18 18:11:52.429: W/dalvikvm(296): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-18 18:11:52.449: E/AndroidRuntime(296): FATAL EXCEPTION: main
03-18 18:11:52.449: E/AndroidRuntime(296): java.lang.NullPointerException
03-18 18:11:52.449: E/AndroidRuntime(296): at com.example.png.StationsListActivity$1.handleMessage(StationsListActivity.java:43)
03-18 18:11:52.449: E/AndroidRuntime(296): at android.os.Handler.dispatchMessage(Handler.java:99)
03-18 18:11:52.449: E/AndroidRuntime(296): at android.os.Looper.loop(Looper.java:123)
03-18 18:11:52.449: E/AndroidRuntime(296): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-18 18:11:52.449: E/AndroidRuntime(296): at java.lang.reflect.Method.invokeNative(Native Method)
3-18 18:11:52.449: E/AndroidRuntime(296): at java.lang.reflect.Method.invoke(Method.java:521)
03-18 18:11:52.449: E/AndroidRuntime(296): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-18 18:11:52.449: E/AndroidRuntime(296): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-18 18:11:52.449: E/AndroidRuntime(296): at dalvik.system.NativeStart.main(Native Method)
Thanks for you precious time!..
Have you added below permission in your manifest.xml?
<uses-permission android:name="android.permission.INTERNET" />
Add Internet permission to your manifest:
<uses-permission android:name="android.permission.INTERNET"/>
Please add internet permission to your manifest.xml file.
<uses-permission android:name="android.permission.INTERNET"/>

Pressing home button while Progress Dialog was showing throws exception

I sent a server request and shown user a progress dialog with following properties
waitDialog = new ProgressDialog(this);
waitDialog.setMessage(getText(R.string.msg_plz_wait));
waitDialog.setIndeterminate(true);
waitDialog.show();
Step1: Sent server request
Step2: Shown User a Dialog
Step3: User presses home button while dialog was visible and showing
Step4: data came from server passed to list adapter but could not found resource and throws Resource not found exception that is handled and then ProgressDialog throws following exception.
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): FATAL EXCEPTION: main
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): java.lang.NullPointerException
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at android.widget.AbsListView.obtainView(AbsListView.java:1432)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at android.widget.ListView.makeAndAddView(ListView.java:1745)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at android.widget.ListView.fillDown(ListView.java:670)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at android.widget.ListView.fillFromTop(ListView.java:727)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at android.widget.ListView.layoutChildren(ListView.java:1598)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at android.widget.AbsListView.onLayout(AbsListView.java:1260)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at android.view.View.layout(View.java:7175)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:912)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at android.view.View.layout(View.java:7175)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:912)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at android.view.View.layout(View.java:7175)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at android.view.View.layout(View.java:7175)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at android.view.View.layout(View.java:7175)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at android.view.ViewRoot.performTraversals(ViewRoot.java:1140)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at android.os.Handler.dispatchMessage(Handler.java:99)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at android.os.Looper.loop(Looper.java:123)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at android.app.ActivityThread.main(ActivityThread.java:3683)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at java.lang.reflect.Method.invokeNative(Native Method)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at java.lang.reflect.Method.invoke(Method.java:507)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): at dalvik.system.NativeStart.main(Native Method)
IMHO, It has nothing to do with the ProgressDialog, But caused by the listview, this is all I could tell based on your question.
It's not you progress dialog.
It's something you are doing, after your server request is ready.
What does happen, if user doesn't press the home button? Does issue still occur?
Have you tried doing waitDialog.setCancelable(false)? Does that make a difference?

Clearing a web page from a view

I am trying to clear a webview from the view in my application.
I clear this by using: MyWebView.loadUrl("about:blank");
This works sometimes, but other times when I load the emulator this gives a force close error:
03-18 14:58:29.560: ERROR/AndroidRuntime(380): FATAL EXCEPTION: main
03-18 14:58:29.560: ERROR/AndroidRuntime(380): java.lang.NullPointerException
03-18 14:58:29.560: ERROR/AndroidRuntime(380): at com.edu.WordJumbleMain$5.onClick(WordJumbleMain.java:168)
03-18 14:58:29.560: ERROR/AndroidRuntime(380): at android.view.View.performClick(View.java:2408)
03-18 14:58:29.560: ERROR/AndroidRuntime(380): at android.view.View$PerformClick.run(View.java:8816)
03-18 14:58:29.560: ERROR/AndroidRuntime(380): at android.os.Handler.handleCallback(Handler.java:587)
03-18 14:58:29.560: ERROR/AndroidRuntime(380): at android.os.Handler.dispatchMessage(Handler.java:92)
03-18 14:58:29.560: ERROR/AndroidRuntime(380): at android.os.Looper.loop(Looper.java:123)
03-18 14:58:29.560: ERROR/AndroidRuntime(380): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-18 14:58:29.560: ERROR/AndroidRuntime(380): at java.lang.reflect.Method.invokeNative(Native Method)
03-18 14:58:29.560: ERROR/AndroidRuntime(380): at java.lang.reflect.Method.invoke(Method.java:521)
03-18 14:58:29.560: ERROR/AndroidRuntime(380): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-18 14:58:29.560: ERROR/AndroidRuntime(380): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-18 14:58:29.560: ERROR/AndroidRuntime(380): at dalvik.system.NativeStart.main(Native Method)
Is there any other way to clear the webview from the view.
Thanks
Raj,
Perhaps you simply want to use the clearView() method?
how to hide the "Web Page not available" text when web View fails to load the page. MyWebView.clearView() is not working.

Categories

Resources