I Am developing an Android application using Socket.Io.When i use my local ip address (192.168.1.22:4000) i got respose from server.But when i use with domain Name ("http://mydomainname.com:80) I got io.socket.SocketIOException: Error while handshaking Exception how can i handle this.Please check below code>thanks in advance.
JSONObject js = new JSONObject();
js.put("key",value);
js.put("key",value);
socket = new SocketIO();
socket = new SocketIO("http://mydomain.com:80");
socket.addHeader("id", 20);
socket.connect(new IOCallback()
{
#Override
public void onMessage(JSONObject json, IOAcknowledge ack)
{
// TODO Auto-generated method stub
System.out.println(".....onMessage.......");
}
#Override
public void onMessage(String data, IOAcknowledge ack)
{
// TODO Auto-generated method stub
System.out.println(".....onMessage... STR....");
}
#Override
public void onError(SocketIOException socketIOException)
{
// TODO Auto-generated method stub
}
#Override
public void onDisconnect()
{
// TODO Auto-generated method stub
}
#Override
public void onConnect()
{
// TODO Auto-generated method stub
System.out.println("....connected ....");
}
#Override
public void on(String event, IOAcknowledge ack, Object... args)
{
// TODO Auto-generated method stub
Object[] arguments = args;
JSONObject jsb = (JSONObject) arguments[0];
} catch (JSONException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
},js,"event name");
} catch (MalformedURLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Related
I'm a newbie in android development. I have to integrate web service in my app but it doesn't work. can someone help me out to resolve it.
Following is the source code
public class Registration extends Activity {
EditText edfnm,edlnm,edmobile,edemail,edpass;
Button b1;
TextView tv1;
private DefaultHttpClient httpclient;
private HttpPost httppost;
private ArrayList<NameValuePair> lst;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_registration);
edfnm=(EditText)findViewById(R.id.edfirst);
edlnm=(EditText)findViewById(R.id.edlast);
edmobile=(EditText)findViewById(R.id.edmobile);
edemail=(EditText)findViewById(R.id.edemail);
edpass=(EditText)findViewById(R.id.edpass);
b1=(Button)findViewById(R.id.btnreg);
tv1=(TextView)findViewById(R.id.textView1);
b1.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
httpclient=new DefaultHttpClient();
httppost=new HttpPost("http://amwaveswellness.com/protocol_suggestion/webservice/register.php");
lst=new ArrayList<NameValuePair>();
lst.add(new BasicNameValuePair("first_name",edfnm.getText().toString()));
lst.add(new BasicNameValuePair("last_name",edlnm.getText().toString()));
lst.add(new BasicNameValuePair("mobile",edmobile.getText().toString()));
lst.add(new BasicNameValuePair("email",edemail.getText().toString()));
lst.add(new BasicNameValuePair("password",edpass.getText().toString()));
try {
httppost.setEntity(new UrlEncodedFormEntity(lst));
new add_data().execute();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
class add_data extends AsyncTask<String, integer, String>{
String jsonstring;
#Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
}
#Override
protected String doInBackground(String... arg0) {
// TODO Auto-generated method stub
try {
HttpResponse httpresponse=httpclient.execute(httppost);
jsonstring=EntityUtils.toString(httpresponse.getEntity());
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return jsonstring;
}
#Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
tv1.setText(result);
Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG).show();
}
}
});
}
When I run this code it returnsnull responce
Pl tell me what's going on and how to tackle it.
API request sample
This is a good example to achieve it.
https://www.simplifiedcoding.net/android-volley-tutorial-to-get-json-from-server/
go through it.
I want to use progress bar... but As I searched, progress bar can not use with Asynctask.get.But I have to use .get and progress in Asynctask.
I made very simple source.
How can I changed to show progress bar in main thread??
I want to use both get method and ui progress.
public void onCreate(Bundle savedInstanceState) {
btn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
AAA asyncTask = new AAA();
try {
((AAA) asyncTask).execute(null, null, null,null).get();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
public class AAA extends AsyncTask<Object, String, Object> {
private ProgressDialog progDailog = null;
#Override
protected void onPreExecute() {
super.onPreExecute();
progDailog = new ProgressDialog(ViewTestActivity.this);
progDailog.setMessage("Loading...");
progDailog.setIndeterminate(false);
progDailog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progDailog.setCancelable(true);
progDailog.show();
}
#Override
protected Object doInBackground(Object... params) {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return params;
}
#Override
protected void onPostExecute(Object result) {
progDailog.dismiss();
}
}
Please help me.
Thanks!!
Do it before calling AsyncTask
private ProgressDialog progDailog = null;
public void onCreate(Bundle savedInstanceState) {
btn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
AAA asyncTask = new AAA();
try {
progDailog = new ProgressDialog(ViewTestActivity.this);
progDailog.setMessage("Loading...");
progDailog.setIndeterminate(false);
progDailog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progDailog.setCancelable(true);
progDailog.show();
((AAA) asyncTask).execute(null, null, null,null);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
public class AAA extends AsyncTask<Object, String, Object> {
#Override
protected Object doInBackground(Object... params) {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return params;
}
#Override
protected void onPostExecute(Object result) {
progDailog.dismiss();
}
}
I don't know if there's a standard answer, but I've just done something very similar by setting up listener on the main thread, and sending progress messages to the listener from the async task - actually in my case it was loading asynchronously from a database. Works fine for me.
Try with this :
private ProgressDialog progDailog;
public void onCreate(Bundle savedInstanceState) {
btn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
progDailog = new ProgressDialog(ViewTestActivity.this);
progDailog.setMessage("Loading...");
progDailog.setIndeterminate(false);
progDailog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progDailog.setCancelable(true);
progDailog.show();
AAA asyncTask = new AAA(progDialog);
try {
((AAA) asyncTask).execute(null, null, null,null).get();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
public class AAA extends AsyncTask<Object, String, Object> {
private ProgressDialog progressDialog;
public AAA (ProgressDialog progressDialog) {
this.progressDialog = progressDialog;
}
#Override
protected Object doInBackground(Object... params) {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return params;
}
#Override
protected void onPostExecute(Object result) {
progressDialog.dismiss();
}
}
you should update your progress bar percentage in onProgressUpdate
See this example AsyncTask with progress bar
This question already has an answer here:
What is the simplest way in Android to keep an objects value after every app run?
(1 answer)
Closed 7 years ago.
I have an android chat application that sends messages from client to server but I am looking for a way to store the send messages in some way, other than being displayed in the list.
Here is part of my application;
public class AndroidChatApplicationActivity extends Activity {
private Handler handler = new Handler();
public ListView msgView;
public ArrayAdapter<String> msgList;
// public ArrayAdapter<String> msgList=new ArrayAdapter<String>(this,
// android.R.layout.simple_list_item_1);;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
msgView = (ListView) findViewById(R.id.listView);
msgList = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1);
msgView.setAdapter(msgList);
// msgView.smoothScrollToPosition(msgList.getCount() - 1);
Button btnSend = (Button) findViewById(R.id.btn_Send);
receiveMsg();
btnSend.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
final EditText txtEdit = (EditText) findViewById(R.id.txt_inputText);
// msgList.add(txtEdit.getText().toString());
sendMessageToServer(txtEdit.getText().toString());
msgView.smoothScrollToPosition(msgList.getCount() - 1);
}
});
Button twitterButton = (Button) findViewById(R.id.website_Button);
twitterButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
sendToWebsite();
}
});
}
protected void sendToWebsite() {
String url = "https://www.ljmu.ac.uk/";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
// receiveMsg();
// ----------------------------
// server msg receieve
// -----------------------
// End Receive msg from server//
public void sendMessageToServer(String str) {
final String str1 = str;
new Thread(new Runnable() {
#Override
public void run() {
// TODO Auto-generated method stub
// String host = "opuntia.cs.utep.edu";
String host = "10.0.2.2";
String host2 = "127.0.0.1";
PrintWriter out;
try {
Socket socket = new Socket(host, 8008);
out = new PrintWriter(socket.getOutputStream());
// out.println("hello");
out.println(str1);
Log.d("", "test");
out.flush();
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.d("", "test2");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.d("", "test3");
}
}
}).start();
}
public void receiveMsg() {
new Thread(new Runnable() {
#Override
public void run() {
// TODO Auto-generated method stub
// final String host="opuntia.cs.utep.edu";
final String host = "10.0.2.2";
// final String host="localhost";
Socket socket = null;
BufferedReader in = null;
try {
socket = new Socket(host, 8008);
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
in = new BufferedReader(new InputStreamReader(
socket.getInputStream()));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
while (true) {
String msg = null;
try {
msg = in.readLine();
Log.d("", "MSGGG: " + msg);
// msgList.add(msg);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (msg == null) {
break;
} else {
displayMsg(msg);
}
}
}
}).start();
}
public void displayMsg(String msg) {
final String mssg = msg;
handler.post(new Runnable() {
#Override
public void run() {
// TODO Auto-generated method stub
msgList.add(mssg);
msgView.setAdapter(msgList);
msgView.smoothScrollToPosition(msgList.getCount() - 1);
Log.d("", "Hi Test");
}
});
}
}
Could anyone suggest a method of storing the messages other than displaying them in a list?
You can try storing them in SharedPreferences. By what I gather, you want store the input so that you can later look at then in a different activity. Have a look at SharedPreferences here http://developer.android.com/reference/android/content/SharedPreferences.html
I am building an app, which is going to have support for facebook.I have downloaded facebook API 3.6.0
The problem is with login - if original FB app is not installed on phone, the login is going through custom dialog
and everything works Fine,but if FB app is installed, the login is going through custom dialog and automatically redirect to original FB app,
and then nothing happened.I have tested this on different phones, and always was the same problem.
I used this link to generate the hashkey.
In my facebook-sdk 3.6.0 I can't find this:
private static boolean ENABLE_LOG = false to true.
Anyone can help? login activity code here :
public class Login extends Activity {
SessionManager session;
EditText etLoginusername;
EditText etLoginPass;
String cus_email, cus_pass, cus_id, cus_mob, cus_name, cus_points, success,
fb_id, id;
Button btnLogin, btnForgotPass, btnfblogin;
ToggleButton remToggle;
int REM_STATUS;
public static Facebook fb;
SharedPreferences sp;
#SuppressWarnings("deprecation")
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
btnfblogin = (Button) findViewById(R.id.Bfb);
btnfblogin.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// fb login code start
String APP_ID = getString(R.string.APP_ID);
fb = new Facebook(APP_ID);
sp = getPreferences(MODE_PRIVATE);
String access_token = sp.getString("access_token", null);
long expires = sp.getLong("access_expires", 0);
if (access_token != null) {
fb.setAccessToken(access_token);
}
if (expires != 0) {
fb.setAccessExpires(expires);
}
// code for generated facebook hash key
try {
PackageInfo info = getPackageManager().getPackageInfo(
"com.amar.facebookexample",
PackageManager.GET_SIGNATURES);
for (android.content.pm.Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
System.out.println("KeyHash : "
+ Base64.encodeToString(md.digest(),
Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
if (fb.isSessionValid()) {
// button logout
try {
fb.logout(getApplicationContext());
fblogin();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
// button Login
fb.authorize(Login.this, new String[] { "email" },
new DialogListener() {
#Override
public void onFacebookError(FacebookError e) {
// TODO Auto-generated method stub
Toast.makeText(Login.this, "fbError",
Toast.LENGTH_SHORT).show();
}
#Override
public void onError(DialogError e) {
// TODO Auto-generated method stub
Toast.makeText(Login.this, "OnError",
Toast.LENGTH_SHORT).show();
}
#Override
public void onComplete(Bundle values) {
// TODO Auto-generated method stub
Editor editor = sp.edit();
editor.putString("access_token",
fb.getAccessToken());
editor.putLong("access_expires",
fb.getAccessExpires());
editor.commit();
session.save(fb, Login.this);
fblogin();
}
#Override
public void onCancel() {
// TODO Auto-generated method stub
Toast.makeText(Login.this, "Oncancel",
Toast.LENGTH_SHORT).show();
}
});
}
}
});
}
#SuppressWarnings("deprecation")
private void fblogin() {
// TODO Auto-generated method stub
if (fb.isSessionValid()) {
JSONObject obj = null;
try {
String jsonUser = fb.request("me");
obj = Util.parseJson(jsonUser);
id = obj.optString("id");
} catch (FacebookError e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("fb_id", id));
String response = null;
try {
response = LoginHttpClient
.executeHttpPost(
"http://10.0.2.2/Upshot_Loyalty_Program/android_api/get_fb_id.php",
postParameters);
JSONObject json = new JSONObject(response);
JSONArray jArray = json.getJSONArray("customer");
for (int i = 0; i < jArray.length(); i++) {
JSONObject json_data = jArray.getJSONObject(i);
success = json_data.getString("success");
cus_id = json_data.getString("cus_id");
cus_name = json_data.getString("cus_name");
cus_points = json_data.getString("cus_points");
// User_List.add(json_data.getString("cus_id"));
}
} catch (Exception e) {
}
if (success.equals("1")) {
session = new SessionManager(getApplicationContext());
session.createLoginSessionRemMe(cus_id, cus_name, cus_points);
Intent i = new Intent(getApplicationContext(), Userpage1.class);
startActivity(i);
} else {
Intent i = new Intent(getApplicationContext(), Mobileno.class);
i.putExtra("fb_id", id);
startActivity(i);
}
}
}
}
This should temporarily solve it
fb.authorize(Login.this, new String[] { "email" },Facebook.FORCE_DIALOG_AUTH, new DialogListener()
I was building a app involving a video player, i have a list view which displays a list of videos and clicking on any of those should play that video. The links i use are rstp youtube links & the video plays fine but when i click back button after the video is played & come to the list again i get Sorry video cant be played error.
Here is my video player class & the list Class:
Video Player class:
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.single);
vid=(VideoView) findViewById(R.id.svid);
iv=(ImageView) findViewById(R.id.simg);
ip=(ImageView) findViewById(R.id.playimg);
t=(TextView) findViewById(R.id.textView1);
final ProgressDialog pd=new ProgressDialog(SingleItem.this);
Intent g=getIntent();
thumb=g.getStringExtra("thumb");
link=g.getStringExtra("link");
msg=g.getStringExtra("msg");
//link="rtsp://v7.cache5.c.youtube.com/CjYLENy73wIaLQmgwjdV-8ZI5BMYJCAkFEIJbXYtZ29vZ2xlSARSBWluZGV4YKSf0bH1u4jEUAw=/0/0/0/video.3gp";
String path1=link;
MediaController mc = new MediaController(this);
mc.setAnchorView(vid);
mc.setMediaPlayer(vid);
uri=Uri.parse(path1);
vid.setMediaController(mc);
vid.setVideoURI(uri);
// vid.requestFocus();
//iv.setClickable(true);
loadImage(thumb);
t.setText(msg);
ip.setClickable(true);
ip.setImageResource(R.drawable.play);
// ip.setVisibility(ImageView.INVISIBLE);
vid.setOnPreparedListener(new OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
// TODO Auto-generated method stub
//ip.setVisibility(ImageView.VISIBLE);
pd.dismiss();
}
});
ip.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
vid.start();
pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
pd.setMessage("Loading Video...");
pd.setIndeterminate(false);
pd.setCancelable(true);
pd.show();
if(vid.isPlaying()){
iv.setVisibility(ImageView.INVISIBLE);
ip.setVisibility(ImageView.INVISIBLE);
}else{
iv.setVisibility(ImageView.VISIBLE);
ip.setVisibility(ImageView.VISIBLE);
vid.stopPlayback();
}
}
});
}
#Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
vid.stopPlayback();
}
#Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
vid.stopPlayback();
}
void loadImage(String image_location){
URL imageURL = null;
try {
imageURL = new URL(image_location);
}
catch (MalformedURLException e) {
e.printStackTrace();
}
try {
HttpURLConnection connection= (HttpURLConnection)imageURL.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream inputStream = connection.getInputStream();
bitmap = BitmapFactory.decodeStream(inputStream);//Convert to bitmap
iv.setImageBitmap(bitmap);
}
catch (IOException e) {
e.printStackTrace();
}
}
}
My List class:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
pf=new PrefMethods(this);
e=(EditText) findViewById(R.id.editText1);
go=(Button) findViewById(R.id.bGo);
e.addTextChangedListener(new TextWatcher() {
#Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
}
#Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
#Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
if(e.getText().length()==0){
adapter=new LazyAdapter(VideoList.this, myList);
//Toast.makeText(getApplicationContext(), "Here finally", 500).show();
list.setAdapter(adapter);
}
}
});
ArrayList<String> items = new ArrayList<String>();
myList = new ArrayList<HashMap<String, String>>();
arr_link = new ArrayList<String>();
arr_thumb = new ArrayList<String>();
arr_msg = new ArrayList<String>();
allItems=new ArrayList<HashMap<String, String>>();
try {
URL urlnew= new URL("link");
HttpURLConnection urlConnection =
(HttpURLConnection) urlnew.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.connect();
// gets the server json data
BufferedReader bufferedReader =
new BufferedReader(new InputStreamReader(
urlConnection.getInputStream()));
String next;
while ((next = bufferedReader.readLine()) != null){
JSONArray ja = new JSONArray(next);
int k=ja.length();
vid_id=pf.loadprefs();
//Toast.makeText(getApplicationContext(), "Here", 500).show();
for (int i = 0; i < ja.length(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
JSONObject jo = (JSONObject) ja.get(i);
WaveData waveData = new WaveData(jo.getString("VUpload"), jo.getInt("recid"),jo.getString("VYoutube"),jo.getString("VMessage"),jo.getString("VThumb"));
if(jo.getInt("recid")>vid_id){
if(i==k-1){
pf.saveprefs(jo.getInt("recid"));
//vid_id=2;
vid_id=jo.getInt("recid");
//Toast.makeText(getApplicationContext(), ""+vid_id, 500).show();
}else{}
}else{}
if(jo.has("VUpload")){
map.put("msg", jo.getString("VMessage"));
map.put("youtube", jo.getString("VYoutube"));
map.put("thumb", jo.getString("VThumb"));
// Toast.makeText(getApplicationContext(), "Here too", 500).show();
myList.add(map);
//Toast.makeText(getApplicationContext(), jo.getString("VMessage"), 500).show();
items.add(jo.getString("VMessage"));
arr_msg.add(jo.getString("VMessage"));
arr_link.add(jo.getString("VYoutube"));
arr_thumb.add(jo.getString("VThumb"));
}
}
}
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
list=(ListView)findViewById(R.id.list);
adapter=new LazyAdapter(this, myList);
//Toast.makeText(getApplicationContext(), "Here finally", 500).show();
list.setAdapter(adapter);
//Toast.makeText(getApplicationContext(), "Set List ", 500).show();
list.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
String l=list.getAdapter().getItem(arg2).toString();
Toast.makeText(getApplicationContext(), l, 500).show();
String sthumb=arr_thumb.get(arg2);
String slink=arr_link.get(arg2);
String smsg=arr_msg.get(arg2);
Intent vid=new Intent(getApplicationContext(), SingleItem.class);
vid.putExtra("link", slink);
vid.putExtra("msg", smsg);
vid.putExtra("thumb", sthumb);
startActivity(vid);
}
});
go.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
allItems.clear();
String l= e.getText().toString();
for(int g=0;g<vid_id;g++){
if(myList.get(g).containsValue(l)){
allItems.add(myList.get(g));
}
}
adapter=new LazyAdapter(VideoList.this, allItems);
// Toast.makeText(getApplicationContext(), "Here finally", 500).show();
list.setAdapter(adapter);
}
});
}
}
The video list gets loaded no issues & even the video plays but when i click the back button it comes back to list & says Sorry,this video cant be played !
Any ideas why the error?
Thanks in advance guys !
Fixed this issue, all i did was made the video stop playing in the onPause & onDestroy method.
Now it works fine without any error