|
I have created android application to stream online radio stations but when I click start button to play radio it won't start.In service I read ip address of file from url and add it to string.When user selects radio station I add port to string with ip address.
public class BackgroundService extends Service implements OnCompletionListener
{
MediaPlayer mediaPlayer;
private String STREAM_URL;
final String textSource = "http://audiophileradio.stream/Ip.txt";
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate()
{
}
@Override
public int onStartCommand(Intent intent, int flags, int startId)
{
new MyTask().execute();
return START_STICKY;
}
public void onDestroy() {
if (mediaPlayer.isPlaying()) {
mediaPlayer.stop();
}
mediaPlayer.release();
}
public void onCompletion(MediaPlayer _mediaPlayer) {
stopSelf();
}
@Override
public boolean onUnbind(Intent intent)
{
return super.onUnbind(intent);
}
private class MyTask extends AsyncTask<Void, Void, String>
{
String textResult;
@Override
protected String doInBackground(Void... params) {
URL textUrl;
try {
textUrl = new URL(textSource);
BufferedReader bufferReader
= new BufferedReader(new InputStreamReader(textUrl.openStream()));
String StringBuffer;
String stringText = "";
while ((StringBuffer = bufferReader.readLine()) != null) {
stringText += StringBuffer;
}
bufferReader.close();
textResult = stringText;
return textResult;
} catch (MalformedURLException e) {
e.printStackTrace();
textResult = e.toString();
} catch (IOException e) {
e.printStackTrace();
textResult = e.toString();
}
return null;
}
@Override
protected void onPostExecute(String result) {
Log.d("DebugTag", "Value: " + textResult);
super.onPostExecute(result);
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(BackgroundService.this);
String radio = sharedPreferences.getString("station", "8000");
if (radio != null)
{
STREAM_URL += ":" + radio;
}
mediaPlayer = new MediaPlayer();
if (!mediaPlayer.isPlaying())
{
try
{
mediaPlayer.reset();
mediaPlayer.setDataSource(STREAM_URL);
mediaPlayer.prepareAsync();
mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener()
{
@Override
public void onPrepared(MediaPlayer mp)
{
mediaPlayer.start();
}
});
} catch (IOException e)
{
e.printStackTrace();
}
}
mediaPlayer.setOnCompletionListener(BackgroundService.this);
}
}
}
Main.java
public class Main extends Fragment
{
private ImageButton buttonPlay;
private MediaPlayer mPlayer;
Intent playbackServiceIntent;
private SeekBar volumeSeekbar = null;
private AudioManager audioManager = null;
View view;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
{
view = inflater.inflate(R.layout.fragment_main,container,false);
buttonPlay = (ImageButton) view.findViewById(R.id.buttonPlay);
mPlayer = new MediaPlayer();
initControls();
buttonPlay.setTag(1);
buttonPlay.setImageResource(R.drawable.play);
buttonPlay.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
if (Integer.parseInt(buttonPlay.getTag().toString()) == 1)
{
buttonPlay.setImageResource(R.drawable.stop);
view.setTag(0);
getActivity().startService(playbackServiceIntent);
Log.e("Play", "onStop");
Toast.makeText(getActivity(), "Play", Toast.LENGTH_SHORT).show();
} else
{
buttonPlay.setImageResource(R.drawable.play);
view.setTag(1);
mPlayer.stop();
getActivity().stopService(playbackServiceIntent);
Log.e("Stop", "onPlay");
Toast.makeText(getActivity(), "Stop", Toast.LENGTH_SHORT).show();
}
}
});
playbackServiceIntent = new Intent(getActivity(), BackgroundService.class);
return view;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
{
super.onViewCreated(view, savedInstanceState);
getActivity().setTitle("Audiophileradio");
}
private void startService()
{
getActivity().startService(new Intent(getActivity(),BackgroundService.class));
}
private void stopService()
{
getActivity().stopService(new Intent(getActivity(),BackgroundService.class));
}
private void initControls()
{
try
{
volumeSeekbar = (SeekBar) view.findViewById(R.id.seekBar);
audioManager = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);
volumeSeekbar.setMax(audioManager
.getStreamMaxVolume(AudioManager.STREAM_MUSIC));
volumeSeekbar.setProgress(audioManager
.getStreamVolume(AudioManager.STREAM_MUSIC));
volumeSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
{
@Override
public void onStopTrackingTouch(SeekBar arg0)
{
}
@Override
public void onStartTrackingTouch(SeekBar arg0)
{
}
@Override
public void onProgressChanged(SeekBar arg0, int progress, boolean arg2)
{
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC,
progress, 0);
}
});
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
modified 13-May-17 9:54am.
|
|
|
|
|
I have fixed the problem! Radio didn't work because I forgot to add http:// in ip address after reading it from url !!!
|
|
|
|
|
I created android application to stream online radio stations but it doesn't work.I want to read ip address from url and assign it to string and when user selects radio to listen I should add port to that string!!!
public class BackgroundService extends Service implements OnCompletionListener
{
MediaPlayer mediaPlayer;
private String STREAM_URL;
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate()
{
final StringBuilder text = new StringBuilder();
new Thread(new Runnable()
{
public void run()
{
try
{
URL url = new URL("http://audiophileradio.stream/Ip.txt");
HttpURLConnection conn=(HttpURLConnection) url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String str;
while ((str = in.readLine()) != null)
{
text.append(str);
}
in.close();
text.insert(text.length(), ":8000");
}
catch (Exception e)
{
Log.d("MyTag",e.toString());
}
}
}).start();
SharedPreferences sharedPreferences =
PreferenceManager.getDefaultSharedPreferences(this);
String radio = sharedPreferences.getString("station", "8000");
if (radio != null && radio.equals("8000"))
{
text.append(":8000");
STREAM_URL = text.toString();
Toast.makeText(this,STREAM_URL,Toast.LENGTH_SHORT).show();
}
if (radio != null && radio.equals("8010"))
{
text.append(":8010");
STREAM_URL = text.toString();
}
if (radio != null && radio.equals("8020"))
{
text.append(":8020");
STREAM_URL = text.toString();
}
if (radio != null && radio.equals("8030"))
{
text.append(":8030");
STREAM_URL = text.toString();
}
mediaPlayer = new MediaPlayer();
try
{
mediaPlayer.setDataSource(STREAM_URL);
} catch (IOException e)
{
e.printStackTrace();
}
mediaPlayer.setOnCompletionListener(this);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId)
{
if (!mediaPlayer.isPlaying())
{
try
{
mediaPlayer.reset();
mediaPlayer.setDataSource(STREAM_URL);
mediaPlayer.prepareAsync();
mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener()
{
@Override
public void onPrepared(MediaPlayer mp)
{
mediaPlayer.start();
}
});
} catch (IOException e)
{
e.printStackTrace();
}
}
return START_STICKY;
}
public void onDestroy() {
if (mediaPlayer.isPlaying()) {
mediaPlayer.stop();
}
mediaPlayer.release();
}
public void onCompletion(MediaPlayer _mediaPlayer) {
stopSelf();
}
@Override
public boolean onUnbind(Intent intent)
{
return super.onUnbind(intent);
}
}
05-12 10:35:48.625 17340-17340/? I/SELinux: Function: selinux_android_load_priority [0], There is no sepolicy file.
05-12 10:35:48.625 17340-17340/? I/SELinux: Function: selinux_android_load_priority [1], There is no sepolicy version file.
05-12 10:35:48.625 17340-17340/? I/SELinux: Function: selinux_android_load_priority , priority version is VE=SEPF_GT-I9301I_4.4.2_0055
05-12 10:35:48.625 17340-17340/? I/SELinux: selinux_android_seapp_context_reload: seapp_contexts file is loaded from /seapp_contexts
05-12 10:35:48.625 17340-17340/? D/dalvikvm: Late-enabling CheckJNI
05-12 10:35:48.835 17340-17340/audiophileradio.example.com.audiophileradio I/dalvikvm: Could not find method android.view.Window.setStatusBarColor, referenced from method audiophileradio.example.com.audiophileradio.MainActivity.onCreate
05-12 10:35:48.835 17340-17340/audiophileradio.example.com.audiophileradio W/dalvikvm: VFY: unable to resolve virtual method 21917: Landroid/view/Window;.setStatusBarColor (I)V
05-12 10:35:48.835 17340-17340/audiophileradio.example.com.audiophileradio D/dalvikvm: VFY: replacing opcode 0x6e at 0x0081
05-12 10:35:48.865 17340-17340/audiophileradio.example.com.audiophileradio I/dalvikvm: Could not find method android.view.Window$Callback.onProvideKeyboardShortcuts, referenced from method android.support.v7.view.WindowCallbackWrapper.onProvideKeyboardShortcuts
05-12 10:35:48.865 17340-17340/audiophileradio.example.com.audiophileradio W/dalvikvm: VFY: unable to resolve interface method 21896: Landroid/view/Window$Callback;.onProvideKeyboardShortcuts (Ljava/util/List;Landroid/view/Menu;I)V
05-12 10:35:48.865 17340-17340/audiophileradio.example.com.audiophileradio D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
05-12 10:35:48.875 17340-17340/audiophileradio.example.com.audiophileradio W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
05-12 10:35:48.875 17340-17340/audiophileradio.example.com.audiophileradio I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
05-12 10:35:48.875 17340-17340/audiophileradio.example.com.audiophileradio W/dalvikvm: VFY: unable to resolve interface method 21898: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
05-12 10:35:48.875 17340-17340/audiophileradio.example.com.audiophileradio D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
05-12 10:35:48.875 17340-17340/audiophileradio.example.com.audiophileradio I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
05-12 10:35:48.875 17340-17340/audiophileradio.example.com.audiophileradio W/dalvikvm: VFY: unable to resolve interface method 21902: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
05-12 10:35:48.875 17340-17340/audiophileradio.example.com.audiophileradio D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
05-12 10:35:48.875 17340-17340/audiophileradio.example.com.audiophileradio I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
05-12 10:35:48.875 17340-17340/audiophileradio.example.com.audiophileradio W/dalvikvm: VFY: unable to resolve virtual method 505: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
05-12 10:35:48.875 17340-17340/audiophileradio.example.com.audiophileradio D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
05-12 10:35:48.875 17340-17340/audiophileradio.example.com.audiophileradio I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
05-12 10:35:48.875 17340-17340/audiophileradio.example.com.audiophileradio W/dalvikvm: VFY: unable to resolve virtual method 527: Landroid/content/res/TypedArray;.getType (I)I
05-12 10:35:48.875 17340-17340/audiophileradio.example.com.audiophileradio D/dalvikvm: VFY: replacing opcode 0x6e at 0x0008
05-12 10:35:48.965 17340-17340/audiophileradio.example.com.audiophileradio I/dalvikvm: Could not find method android.content.Context.getColorStateList, referenced from method android.support.v7.content.res.AppCompatResources.getColorStateList
05-12 10:35:48.965 17340-17340/audiophileradio.example.com.audiophileradio W/dalvikvm: VFY: unable to resolve virtual method 316: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList;
05-12 10:35:48.965 17340-17340/audiophileradio.example.com.audiophileradio D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
05-12 10:35:49.175 17340-17340/audiophileradio.example.com.audiophileradio I/dalvikvm: Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawable
05-12 10:35:49.175 17340-17340/audiophileradio.example.com.audiophileradio W/dalvikvm: VFY: unable to resolve virtual method 468: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
05-12 10:35:49.175 17340-17340/audiophileradio.example.com.audiophileradio D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
05-12 10:35:49.175 17340-17340/audiophileradio.example.com.audiophileradio I/dalvikvm: Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawableForDensity
05-12 10:35:49.175 17340-17340/audiophileradio.example.com.audiophileradio W/dalvikvm: VFY: unable to resolve virtual method 470: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
05-12 10:35:49.175 17340-17340/audiophileradio.example.com.audiophileradio D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
05-12 10:35:49.185 17340-17340/audiophileradio.example.com.audiophileradio E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
05-12 10:35:49.185 17340-17340/audiophileradio.example.com.audiophileradio W/dalvikvm: VFY: unable to resolve instanceof 150 (Landroid/graphics/drawable/RippleDrawable;) in Landroid/support/v7/widget/AppCompatImageHelper;
05-12 10:35:49.185 17340-17340/audiophileradio.example.com.audiophileradio D/dalvikvm: VFY: replacing opcode 0x20 at 0x000c
05-12 10:35:49.315 17340-17340/audiophileradio.example.com.audiophileradio D/ProgressBar: setProgressDrawable drawableHeight = 24
05-12 10:35:49.335 17340-17340/audiophileradio.example.com.audiophileradio D/AbsSeekBar: AbsSeekBar Constructor: misSeebarAnimationAvailable = false
05-12 10:35:49.345 17340-17340/audiophileradio.example.com.audiophileradio D/ProgressBar: setProgressDrawable drawableHeight = 24
05-12 10:35:49.345 17340-17340/audiophileradio.example.com.audiophileradio D/ProgressBar: setProgressDrawable getHeight() = 0
05-12 10:35:49.345 17340-17340/audiophileradio.example.com.audiophileradio D/ProgressBar: updateDrawableBounds: left = 0
05-12 10:35:49.345 17340-17340/audiophileradio.example.com.audiophileradio D/ProgressBar: updateDrawableBounds: top = 0
05-12 10:35:49.345 17340-17340/audiophileradio.example.com.audiophileradio D/ProgressBar: updateDrawableBounds: right = -64
05-12 10:35:49.345 17340-17340/audiophileradio.example.com.audiophileradio D/ProgressBar: updateDrawableBounds: bottom = 0
05-12 10:35:49.345 17340-17340/audiophileradio.example.com.audiophileradio D/ProgressBar: updateDrawableBounds: mProgressDrawable.setBounds()
05-12 10:35:49.365 17340-17340/audiophileradio.example.com.audiophileradio V/MediaPlayer-JNI: native_setup
05-12 10:35:49.365 17340-17340/audiophileradio.example.com.audiophileradio V/MediaPlayer: constructor
05-12 10:35:49.365 17340-17340/audiophileradio.example.com.audiophileradio V/MediaPlayer: setListener
05-12 10:35:49.365 17340-17340/audiophileradio.example.com.audiophileradio E/MediaPlayer-JNI: QCMediaPlayer mediaplayer NOT present
05-12 10:35:49.405 17340-17340/audiophileradio.example.com.audiophileradio V/MediaPlayer-JNI: native_setup
05-12 10:35:49.405 17340-17340/audiophileradio.example.com.audiophileradio V/MediaPlayer: constructor
05-12 10:35:49.405 17340-17340/audiophileradio.example.com.audiophileradio V/MediaPlayer: setListener
05-12 10:35:49.405 17340-17340/audiophileradio.example.com.audiophileradio E/MediaPlayer-JNI: QCMediaPlayer mediaplayer NOT present
05-12 10:35:49.415 17340-17340/audiophileradio.example.com.audiophileradio D/dalvikvm: DexOpt: couldn't find field Landroid/app/Notification;.headsUpContentView
05-12 10:35:49.415 17340-17340/audiophileradio.example.com.audiophileradio W/dalvikvm: VFY: unable to resolve instance field 14
05-12 10:35:49.415 17340-17340/audiophileradio.example.com.audiophileradio D/dalvikvm: VFY: replacing opcode 0x5b at 0x005d
05-12 10:35:49.415 17340-17340/audiophileradio.example.com.audiophileradio D/dalvikvm: DexOpt: couldn't find field Landroid/app/Notification;.headsUpContentView
05-12 10:35:49.415 17340-17340/audiophileradio.example.com.audiophileradio W/dalvikvm: VFY: unable to resolve instance field 14
05-12 10:35:49.415 17340-17340/audiophileradio.example.com.audiophileradio D/dalvikvm: VFY: replacing opcode 0x5b at 0x004c
05-12 10:35:49.415 17340-17340/audiophileradio.example.com.audiophileradio D/dalvikvm: DexOpt: couldn't find field Landroid/app/Notification;.headsUpContentView
05-12 10:35:49.415 17340-17340/audiophileradio.example.com.audiophileradio I/dalvikvm: DexOpt: unable to optimize instance field ref 0x000e at 0x54 in Landroid/support/v7/app/NotificationCompat;.addHeadsUpToBuilderLollipop
05-12 10:35:49.415 17340-17340/audiophileradio.example.com.audiophileradio D/dalvikvm: DexOpt: couldn't find field Landroid/app/Notification;.headsUpContentView
05-12 10:35:49.415 17340-17340/audiophileradio.example.com.audiophileradio I/dalvikvm: DexOpt: unable to optimize instance field ref 0x000e at 0x61 in Landroid/support/v7/app/NotificationCompat;.addHeadsUpToBuilderLollipop
05-12 10:35:49.485 17340-17340/audiophileradio.example.com.audiophileradio I/Adreno-EGL: <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: ()
OpenGL ES Shader Compiler Version: E031.24.00.07
Build Date: 01/27/14 Mon
Local Branch: base_au149_adreno_au169_patches
Remote Branch:
Local Patches:
Reconstruct Branch:
05-12 10:35:49.605 17340-17340/audiophileradio.example.com.audiophileradio D/OpenGLRenderer: Enabling debug mode 0
05-12 10:35:49.615 17340-17340/audiophileradio.example.com.audiophileradio D/ProgressBar: updateDrawableBounds: left = 0
05-12 10:35:49.615 17340-17340/audiophileradio.example.com.audiophileradio D/ProgressBar: updateDrawableBounds: top = 0
05-12 10:35:49.615 17340-17340/audiophileradio.example.com.audiophileradio D/ProgressBar: updateDrawableBounds: right = 568
05-12 10:35:49.615 17340-17340/audiophileradio.example.com.audiophileradio D/ProgressBar: updateDrawableBounds: bottom = 68
05-12 10:35:49.615 17340-17340/audiophileradio.example.com.audiophileradio D/ProgressBar: updateDrawableBounds: mProgressDrawable.setBounds()
05-12 10:35:49.625 17340-17340/audiophileradio.example.com.audiophileradio I/dalvikvm: Could not find method android.support.v7.widget.LinearLayoutCompat.drawableHotspotChanged, referenced from method android.support.design.internal.ForegroundLinearLayout.drawableHotspotChanged
05-12 10:35:49.625 17340-17340/audiophileradio.example.com.audiophileradio W/dalvikvm: VFY: unable to resolve virtual method 18400: Landroid/support/v7/widget/LinearLayoutCompat;.drawableHotspotChanged (FF)V
05-12 10:35:49.625 17340-17340/audiophileradio.example.com.audiophileradio D/dalvikvm: VFY: replacing opcode 0x6f at 0x0000
05-12 10:36:19.895 17340-17340/audiophileradio.example.com.audiophileradio E/Play: onPlay
05-12 10:36:19.955 17340-17340/audiophileradio.example.com.audiophileradio V/MediaPlayer-JNI: native_setup
05-12 10:36:19.955 17340-17340/audiophileradio.example.com.audiophileradio V/MediaPlayer: constructor
05-12 10:36:19.965 17340-17340/audiophileradio.example.com.audiophileradio V/MediaPlayer: setListener
05-12 10:36:19.965 17340-17340/audiophileradio.example.com.audiophileradio E/MediaPlayer-JNI: QCMediaPlayer mediaplayer NOT present
05-12 10:36:20.005 17340-17340/audiophileradio.example.com.audiophileradio E/MediaPlayer: Unable to create media player
05-12 10:36:20.005 17340-17352/audiophileradio.example.com.audiophileradio V/MediaPlayer: message received msg=8, ext1=0, ext2=0
05-12 10:36:20.005 17340-17352/audiophileradio.example.com.audiophileradio V/MediaPlayer: notify(8, 0, 0) callback on disconnected mediaplayer
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: java.io.IOException: setDataSource failed.: status=0x80000000
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at android.media.MediaPlayer._setDataSource(Native Method)
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1317)
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1240)
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at audiophileradio.example.com.audiophileradio.BackgroundService.onCreate(BackgroundService.java:107)
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at android.app.ActivityThread.handleCreateService(ActivityThread.java:2736)
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at android.app.ActivityThread.access$1900(ActivityThread.java:169)
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1359)
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at android.os.Looper.loop(Looper.java:136)
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5476)
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at java.lang.reflect.Method.invokeNative(Native Method)
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at java.lang.reflect.Method.invoke(Method.java:515)
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at dalvik.system.NativeStart.main(Native Method)
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio V/MediaPlayer: isPlaying: no active player
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio V/MediaPlayer-JNI: isPlaying: 0
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio V/MediaPlayer-JNI: reset
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio V/MediaPlayer: reset
05-12 10:36:20.015 17340-17352/audiophileradio.example.com.audiophileradio V/MediaPlayer: message received msg=8, ext1=0, ext2=0
05-12 10:36:20.015 17340-17352/audiophileradio.example.com.audiophileradio V/MediaPlayer: notify(8, 0, 0) callback on disconnected mediaplayer
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio E/MediaPlayer: Unable to create media player
05-12 10:36:20.015 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: java.io.IOException: setDataSource failed.: status=0x80000000
05-12 10:36:20.025 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at android.media.MediaPlayer._setDataSource(Native Method)
05-12 10:36:20.025 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1317)
05-12 10:36:20.025 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1240)
05-12 10:36:20.025 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at audiophileradio.example.com.audiophileradio.BackgroundService.onStartCommand(BackgroundService.java:124)
05-12 10:36:20.025 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2883)
05-12 10:36:20.025 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at android.app.ActivityThread.access$2200(ActivityThread.java:169)
05-12 10:36:20.025 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1374)
05-12 10:36:20.025 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
05-12 10:36:20.025 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at android.os.Looper.loop(Looper.java:136)
05-12 10:36:20.025 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5476)
05-12 10:36:20.025 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at java.lang.reflect.Method.invokeNative(Native Method)
05-12 10:36:20.025 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at java.lang.reflect.Method.invoke(Method.java:515)
05-12 10:36:20.025 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
05-12 10:36:20.025 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
05-12 10:36:20.035 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
05-12 10:36:20.035 17340-17340/audiophileradio.example.com.audiophileradio W/System.err: at dalvik.system.NativeStart.main(Native Method)
05-12 10:36:20.195 17340-19228/audiophileradio.example.com.audiophileradio I/System.out: Thread-66912(HTTPLog):isShipBuild true
05-12 10:36:20.195 17340-19228/audiophileradio.example.com.audiophileradio I/System.out: Thread-66912(HTTPLog):SmartBonding Enabling is false, SHIP_BUILD is true, log to file is false, DBG is false
05-12 10:36:20.425 17340-19228/audiophileradio.example.com.audiophileradio D/MyTag: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
|
|
|
|
|
Depending on how long it takes your thread code to finish parsing http://audiophileradio.stream/Ip.txt, your preferences/append code is also accessing the text variable. What's the possibility of that happening out of order?
Pavlex4 wrote: mediaPlayer.setDataSource(STREAM_URL); Have you tried hard-coding the value passed to setDataSource() to see if the reset of your player-related code is correct?
This is unrelated to the problem you are having, but the four if() tests are not as efficient as they could be. You are checking radio 's value four more times than is necessary. Consider:
if (radio != null)
{
text.append(':').append(radio);
STREAM_URL = text.toString();
Toast.makeText(this, STREAM_URL, Toast.LENGTH_SHORT).show();
}
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hello Regards,
How to Develop Shopping cart in Android,With PHP MYSQL Database Connectivity,and After that it will redirect to the payment module.
As i am doing Payment with Instamojo the Payment app is ready as well as static Shopping Cart is ready...But How to Connect with Database...
Kindly Help Me,I am Working On this Project Since last two weeks but nothing is fruitful.
Help me.
Thanking You,
Bhrugesh Shah
Bhrugesh Shah
|
|
|
|
|
|
Member 13196220 wrote: How to Develop Shopping cart in Android,With PHP MYSQL Database Connectivity... That's at least three separate items (that can come together to eventually make your desired app). Have you tried to get each one working independently of the other?
Member 13196220 wrote: I am Working On this Project Since last two weeks but nothing is fruitful. So which part is troubling you, specifically?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hi Sifu..
I need some advice to properly implement MVVM with what I'm trying to do.
1) I have a WebView control in a View because I need user to manually login to a website.
2) Once login, it will set a flag to indicate that user has logged in. It will then go to another link in the website and periodically read a html element value.
3) The values read will then be displayed in a table in another View.
4) In the scenario when the user is logged off from the website, it will show the website login page again. And then it will continue to Step 2 and Step 3.
5) The View that has the WebView control only need to be shown for the user to log in to the website. After logging in, the View can be hidden, and only showing the table which contains the values read, which are periodically updated.
I have few ideas on how to implement it but I am not sure if my idea is correct or not.
Idea 1:
Have 2 View/ViewModel pair. 1 View/ViewModel (VM1) to display out the readings read. Another View/ViewModel (VM2) which contains WebView control for the user to login. VM1 will periodically trigger VM2 (by using mediator pattern) to read from the website. As VW2 tries to read from the website, if the user is not logged in to the website, it will go to the log in page. Once the user has logged in, it will go to the webpage that contains the html element and read the value. It will stay in that webpage so that the next time VW1 triggers VM2 to read the value, it can readily do so without user intervention.
Eventhough user may close the VM2's View, the View is not really closed. It is just hidden and the program is still able to read from the webpage in the background.
Idea 2:
Have View/ViewModel (VM1) to display out the value in the table. VM1 calls a service that does the reading of webpage. The service has a WebView control. If the user is not logged in, the service will instantiate a View/ViewModel (VM2) and passing in the WebView control which the user can use to log in. Once the user has logged in, the WebView control is passed back to the service so that the service can continue to read the html element. The service then triggers the ViewModel (VM2) to close the View.
Please advice on what is the correct MVVM way to do what I'm trying to do.
Thanks.
modified 10-May-17 18:00pm.
|
|
|
|
|
JoJo82 wrote: Hi Sifus Who is Sifus, and why do you think he/she will see this message?
|
|
|
|
|
Hi Richard.. forgive me for the misunderstanding..
Sifus is referring to Teacher/Master in Chinese because I'm still learning and there are a lot of very experienced people in this forum.
Actually, it is Sifu.. I just use Sifus to make it plural..
|
|
|
|
|
I have created android application with navigation drawer and when I click item from navigation drawer old fragment is not replaced,I can still see the old fragment under the new fragment.How to fix this issue?
private void displaySelectedScreen(int id)
{
Fragment fragment = null;
switch (id)
{
case R.id.home:
fragment = new Main();
break;
case R.id.settings:
Intent intent = new Intent(this, Settings.class);
startActivity(intent);
break;
case R.id.about:
Intent intent1 = new Intent(this, About.class);
startActivity(intent1);
break;
case R.id.share:
try
{
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_SUBJECT, "Audiophileradio");
String sAux = "\nLet me recommend you this application\n\n";
sAux = sAux + "https://play.google.com/store/apps/details?id=Orion.Soft \n\n";
i.putExtra(Intent.EXTRA_TEXT, sAux);
startActivity(Intent.createChooser(i, "choose one"));
}
catch(Exception e)
{
}
break;
case R.id.send:
fragment = new Feedback();
break;
}
if (fragment != null)
{
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.contentFrame, fragment).commit();
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item)
{
int id = item.getItemId();
displaySelectedScreen(id);
return true;
}
content_main.xml
="1.0"="utf-8"
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="audiophileradio.example.com.audiophileradio.MainActivity"
tools:showIn="@layout/app_bar_main"
android:background="@drawable/backg1">
<FrameLayout
android:id="@+id/contentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</FrameLayout>
<TextView
android:id="@+id/textView3"
android:layout_width="13dp"
android:layout_height="21dp"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:text="+"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.977"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.13"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"/>
feedback.xml
="1.0"="utf-8"
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:text="Title :"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.103"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.081"/>
<EditText
android:id="@+id/editText"
android:layout_width="218dp"
android:layout_height="35dp"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="8dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_bias="0.593"
app:layout_constraintVertical_bias="0.084"
android:background="@drawable/border"/>
</android.support.constraint.ConstraintLayout
|
|
|
|
|
See here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hello everyone i need to hashed my password when i put it in my login application android and then i need to compare it with my password in my table fos_user of symfony and the password in fos_user is encoders:bcrypt
This is my code:
<?php
include 'config.inc.php';
if(isset($_POST['username']) && isset($_POST['password']))
{
$result='';
$username = $_POST['username'];
$password = $_POST['password'];
$hash = password_hash($password, PASSWORD_BCRYPT);
$sql = "SELECT password FROM fos_user WHERE username = '$username' AND password = '$hash'";
$test = mysql_query($sql) or die( mysql_error() );
$row = mysql_fetch_assoc($test);
if ($hash == $row['password'])
{
$result="true";
}
else
{
$result="false";
}
echo $result;
}
?>
My file config.inc.php is this code
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "projet_grh";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e)
{
die("OOPs something went wrong");
}
?>
|
|
|
|
|
What does this have to do with Android programming? More importantly, what is the problem?
|
|
|
|
|
i need to compare the password in my application Android in the login with my password in my database
|
|
|
|
|
So what is (not) working?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
i cant login when i grap my username and my password i thnik there are a problem in my code php but i don't find it
|
|
|
|
|
Member 13023118 wrote: ...i thnik there are a problem in my code php but i don't find it Perhaps you'd be better served here. Once your PHP code is returning the proper credentials, then you can come back to this forum and focus on your Android code.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
ok thank you very much
|
|
|
|
|
So where is this PHP code running, where is the database, and what application on the Android system is connected to it?
|
|
|
|
|
i have a file named test.rar which have password that i set on it ,cuz i have a database file in it ,
i want to open this file and read data from my database file and use it for my app in android studio .
how can i do it ?
|
|
|
|
|
What problem are you having (other than needing all of this code to exist)?
|
|
|
|
|
You already posted this question in QA - How to open a rar file with password[^]
I asked you some questions on that post.
Do not post the same question in multiple forums on this site - it's rude.
|
|
|
|
|
Store the .rar file in your project's assets folder. During runtime, you can access and save that file to the phone's internal storage or the SD card. As I understand it, RAR is a propriatary format so you can't unarchive it using Java's SDK. Use a third party library like junrar to do the unarchiving.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
modified 25-Apr-17 10:00am.
|
|
|
|
|
I am working with googlemap. I have implemented custom marker window, this window contains photo of the marker. I am taking the url of the photo as string and setting it into imageview with thread. However, the code is not syncronized with user. When I have clicked the marker, it shows the photo of the previeus marker that I have clicked. When I did debug, I can see that true url values are coming from background but the setting image into imageview operation is becoming late. How can I solve this problem? I have tried picasso and glide but still same problem.
@Override
public void onMapReady(GoogleMap map) {
this.infoWindow = (ViewGroup)getActivity().getLayoutInflater().inflate(R.layout.info_marker_window, null);
this.mekanfoto = (ImageView) infowindow.findViewById(R.id.mekan_foto);
googleMap = map;
if(googleMap!=null){
googleMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker marker) {
return null;
}
@Override
public View getInfoContents(final Marker marker) {
if(mLastLocation.getLatitude()!=marker.getPosition().latitude||
mLastLocation.getLongitude()!=marker.getPosition().longitude){
customMarker = CustomMarker.getCustomMarker(listCustomMarker, marker);
final String URL = customMarker.getVenue().getFoto();
createThread(mekanfoto,URL).start();
mapWrapperLayout.setMarkerWithInfoWindow(marker, infoWindow);
return infoWindow;
}
return null;}
});
}
}
private synchronized Thread createThread(final ImageView imageView, final String URL)
{
final Bitmap[] b = new Bitmap[1];
Thread thread=new Thread(new Runnable() {
@Override
public void run() {
b[0] =download_Image(URL,imageView);
}
});
return thread;
}
public Bitmap download_Image(String url,ImageView imageview) {
URL newurl = null;
try {
newurl = new URL(url);
} catch (MalformedURLException e) {
e.printStackTrace();
}
Bitmap mIcon_val = null;
try {
URLConnection urlConnection=newurl.openConnection();
InputStream is=urlConnection.getInputStream();
mIcon_val= BitmapFactory.decodeStream(is);
} catch (Exception e) {
e.printStackTrace();
}finally {
}
imageview.setImageBitmap(mIcon_val);
return mIcon_val;
}
modified 18-Apr-17 12:31pm.
|
|
|
|
|