|
My app crashes always when displaying listview with youtube thumbnail. I've created this app with AsyncTask,in doInBackground i'm fetching youtube video id and title which is in json... Then in onPostExecute i'm inflating my youtube view layout with customadapter and adding thumbnail for each list items in listview. But my app crashes always when doing this process... I used this listview with youtube thumbnail without getting title and video id from json(I did normal string array of title and video id,so there is no problem with my custom adapter.it works fine)I heard that if an app delay to get views for 5 secs,it'll automatically crashes... Is it true ? and Please help me what to do for this issue.. I'm new to Android...
|
|
|
|
|
An application crashes when the code you wrote is wrong...However we can not say what wrong with it if we can't see it...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
MainActivity
protected void onPostExecute(Integer result){
if(result == 1){
Toast.makeText(getApplicationContext(),"Result = 1",Toast.LENGTH_SHORT).show();
if(progressDialog.isShowing()){
progressDialog.dismiss();
}
Toast.makeText(getApplicationContext(),"onPostExecute",Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),VideoID[0],Toast.LENGTH_SHORT).show();
CustomAdapter customAdapter = new CustomAdapter(context,Title,VideoID);
listView.setAdapter(arrayAdapter);
CustomAdapter
public CustomAdapter(Activity context,String[] Title,String[] VideoID){
super(context,R.layout.activity_main,VideoID);
this.context = context;
this.Title = Title;
this.VideoID = VideoID;
}
@Override
public View getView(final int position,View convertView,ViewGroup parent){
View ListItemView = convertView;
if (convertView == null){
LayoutInflater inflater = context.getLayoutInflater();
ListItemView = inflater.inflate(R.layout.youtubethumbnail_loader,null,false);
}
youTubeThumbnailView = (YouTubeThumbnailView)ListItemView.findViewById(R.id.youtubethumbnailviewnew);
youTubeThumbnailView.initialize(Config.API_KEY, new YouTubeThumbnailView.OnInitializedListener() {
@Override
public void onInitializationSuccess(YouTubeThumbnailView thumbnailView, YouTubeThumbnailLoader thumbnailLoader) {
Toast.makeText(context,"Success initialization",Toast.LENGTH_SHORT).show();
youTubeThumbnailLoader = thumbnailLoader;
thumbnailLoader.setOnThumbnailLoadedListener(new YouTubeThumbnailLoader.OnThumbnailLoadedListener() {
@Override
public void onThumbnailLoaded(YouTubeThumbnailView youTubeThumbnailView, String s) {
Toast.makeText(context, "Welcome to ShortFilmy", Toast.LENGTH_SHORT).show();
}
@Override
public void onThumbnailError(YouTubeThumbnailView youTubeThumbnailView, YouTubeThumbnailLoader.ErrorReason errorReason) {
Toast.makeText(context, "Failed to load thumbnail", Toast.LENGTH_SHORT).show();
}
});
thumbnailLoader.setVideo(VideoID[position]);
}
@Override
public void onInitializationFailure(YouTubeThumbnailView youTubeThumbnailView, YouTubeInitializationResult youTubeInitializationResult) {
Toast.makeText(context,"Failed to initialize",Toast.LENGTH_SHORT).show();
}
});
textView = (TextView)ListItemView.findViewById(R.id.textViewnew);
textView.setText(Title[position]);
return ListItemView;
}
}
Here,my customadapter is working fine when i used without asynctask but if I call customadapter class in asynctask(onPostExecute method) it'll force close my app. I googled a lot about this but i didn't know what to do for this.. But I heard that every app wants to view the widgets or anything within 5 secs in UI thread otherwise our app got crashed.So you guys wanna help me out...
|
|
|
|
|
Member 12263477 wrote: I googled a lot about this Did you try some debugging of your application? You need to identify where the crash occurred and what were the circumstances at the time. Only then will you be able to start figuring out why it crashed.
|
|
|
|
|
Help guys, I don't know how to inflate youtubethumbnailview layout and to add it in list items. I'm fetching video id and title from json... If anyone have source code for this ??? Please help me. Thanks in advanced
|
|
|
|
|
Typically, you inflate entire XML file for that view. I have never used this, but I think it would be used in a layout (RelativeLayout or LinearLayout), just like any other control.
From the following blog, the code would be something like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<com.google.android.youtube.player.YouTubeThumbnailView
android:id="@+id/thumbnailview"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Then, you can inflate it using any LayoutInflater object, get it using getLayoutInflater() .
Android Coding: Display YouTubeThumbnailView of YouTube Android Player API[^]
https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/YouTubeThumbnailView?hl=en
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
i'am trying to send string to webservice and get replay from.
i use android studio for programming on java for android
and visual-studio 2010 for programming the C# webservice.
i have this code on android
private static final String SOAP_ACTION = "http://tempuri.org/HELO";
private static final String OPERATION_NAME = "HELO";
private static final String WSDL_TARGET_NAMESPACE = "<a href="http:
private static final String SOAP_ADDRESS = "<a href="http:
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE, OPERATION_NAME);
PropertyInfo info= new PropertyInfo();
info = new PropertyInfo();
info.setName("HELO");
info.setValue("New User");
info.setType(String.class);
request.addProperty(info);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
try {
httpTransport.call(SOAP_ACTION, envelope);
Object response = envelope.getResponse();
tvData1.setText(response.toString());
} catch (Exception exception) {
tvData1.setText(exception.toString());
}
and this my C# WebService
[WebService(Namespace = "<a href="http://tempuri.org/">http://tempuri.org/</a>")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public string HELO(string Name)
{
return "Hello : " + Name;
}
}
and i got only Helo: without the string that i send instead of Helo: New User
thans
|
|
|
|
|
I would suggest debugging to see if WCF is capturing the value being passed or not. It may be caused by the value not being passed to the function, or value being empty string or something.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Dears
I want to send data form one activity to another activity
i use intent to send data when i use on item click listener
this this my code for first activity
<blockquote class="quote"><div class="op">Quote:</div>lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent i = new Intent(getApplicationContext(),Details.class);
i.putExtra("id",position);
startActivity(i);
}
});</blockquote>
know the second activity
to get intnet is
ublic class Details extends AppCompatActivity {
DBAdapter myDbHelper = new DBAdapter(this);
SQLiteDatabase database;
int item;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_details);
TextView t1=(TextView)findViewById(R.id.t1);
ImageButton im=(ImageButton)findViewById(R.id.im);
Intent data=getIntent();
int des=data.getIntExtra("id", 1);
try {
String query = "SELECT description FROM sweet WHERE id = " + des + "";
database=myDbHelper.openDataBase();
database = myDbHelper.getReadableDatabase();
Cursor cursor = database.rawQuery(query, null);
cursor.getCount();
cursor.moveToFirst();
String description= cursor.getColumnName(2);
t1.setText(description);
}
know i want to use intent to use it in sql statment to search
in my table and get the details in the column description
and put the text of details in text view
can any one help me
|
|
|
|
|
|
|
What is the value of query ?
So what EXACTLY is the problem?
"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-Jan-16 8:43am.
|
|
|
|
|
who to use the get intent to use the position of item to serche in database
|
|
|
|
|
Muhammad H Alhasanat wrote: who... You want to know WHO can use it? That seems an odd question.
Anyway, have you stepped through the code line by line using the debugger to see what is going on? What is the value of des ? Of query ?
"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
|
|
|
|
|
the value is get intent form first activity
|
|
|
|
|
So the value of query is "get intent form first activity"? Well no wonder your code does not work; That is not a valid SELECT statement!
"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
|
|
|
|
|
It is quite a simple matter to display the full text of your query to see exactly what values it contains.
|
|
|
|
|
What's the difference between creating objects
Code 1:
ArrayList<String> arraylist = new ArrayList<String>();
and
List<String> arraylist = new ArrayList<String>();
Then what is this
List<Map<String,String>> countryList = new ArrayList<Map<String,String>>(); Why we're using Map inside this ? Please anyone help me to understand... I'm learning json parsing in android.
I know about arraylist and maps.. Explain me clearly please.... Thanks in advanced 
|
|
|
|
|
Member 12263477 wrote: Explain me clearly please It is an array of Maps, but with so little context it is difficult to know its purpose. Maybe you should ask the person who wrote the code.
|
|
|
|
|
Hi,
I have a list view i am showing some messahes from Database like
db.Query<Conversation>("select * from (select * from Conversation where OpponentName = ? order by Id desc limit 20) order by Id asc", opponentName); and i am limiting 20 out of 50, after that i have show remaining 20 while pull at 0'th item in a list.
i am able to get first 20 but i am not able to get remaining 20.
Can eney one help me to solve it.
Thanks in advance
modified 22-Jan-16 4:41am.
|
|
|
|
|
Remove the swipe and listview from the problem, and focus on the query. How would you retrieve items 21-40? I suspect a WHERE is needed.
"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
|
|
|
|
|
In Android both defaulthttpclient,httpentity,httpresponse all are deprecated then what's the alternative ? I'm new to http request and responses... Now i'm wanna retrieve the contents from json which is hosted in server. So what i wanna do ? Shall i use these deprecated methods ? is there any problem using it ? please help me with this... Thanks in advanced 
|
|
|
|
|
|
So I want to use httpurlconnection class instead defaulthttpclient class? Thanks for your reply
|
|
|
|
|
Hello,I'm new to here.. I've created a simple app using YouTube API it contains a collections of list item if any one touch the list item then it'll redirect you into youtube for particular video.Now the thing is I want to add youtube thumbnail with list item of list view. Is there any way to add image there ? Please any one shed some light on this question ?
Activity Main xml
="1.0"="utf-8"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.vinothvino.shortfilmy.MainActivity">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/listView"
android:layout_gravity="center_vertical"
android:layout_weight="1" />
<com.google.android.youtube.player.YouTubeThumbnailView
android:id="@+id/youtube_thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp">
</com.google.android.youtube.player.YouTubeThumbnailView>
</LinearLayout>
YouTubeView xml
="1.0"="utf-8"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".YouTubeView">
<com.google.android.youtube.player.YouTubeThumbnailView
android:id="@+id/youtube_thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp">
</com.google.android.youtube.player.YouTubeThumbnailView>
<com.google.android.youtube.player.YouTubePlayerView
android:id="@+id/youtube_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
ListView
="1.0"="utf-8"
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listviewadapter"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="25dip"
android:textSize="16dip"
android:textStyle="bold" >
</TextView>
MainActivity
package com.example.vinothvino.shortfilmy;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.view.View;
import android.widget.Toast;
public class MainActivity extends Activity {
ListView listView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String[] shortFilms = {"Mudhal Kanave","A Cute Love story","Ennai Saaithaale","Friend ah Figure ah",
"Perfect You","Aparam","Yaaro Ivan","Honey Money Romantic Thriller"};
listView = (ListView) findViewById(R.id.listView);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout.list_view,shortFilms);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
int itemPos = position;
String itemVal = (String)listView.getItemAtPosition(itemPos);
switch (itemPos){
case 0:
Intent i = new Intent(getApplicationContext(),YouTubeView.class);
i.putExtra("value1","rk7NYXql2dc");
startActivity(i);
Toast.makeText(getApplicationContext(),itemVal,Toast.LENGTH_SHORT).show();
break;
case 1:
Intent i1 = new Intent(getApplicationContext(),YouTubeView.class);
i1.putExtra("value1", "j1lc8p8NFNw");
startActivity(i1);
Toast.makeText(getApplicationContext(),itemVal,Toast.LENGTH_SHORT).show();
break;
case 2:
Intent i2 = new Intent(getApplicationContext(),YouTubeView.class);
i2.putExtra("value1","8au0FflDO-I");
startActivity(i2);
Toast.makeText(getApplicationContext(),itemVal,Toast.LENGTH_SHORT).show();
break;
case 3:
Intent i3 = new Intent(getApplicationContext(),YouTubeView.class);
i3.putExtra("value1","9daIXm6lSTc");
startActivity(i3);
Toast.makeText(getApplicationContext(),itemVal,Toast.LENGTH_SHORT).show();
break;
case 4:
Intent i4 = new Intent(getApplicationContext(),YouTubeView.class);
i4.putExtra("value1","s3s838owcOY");
startActivity(i4);
Toast.makeText(getApplicationContext(),itemVal,Toast.LENGTH_SHORT).show();
break;
case 5:
Intent i5 = new Intent(getApplicationContext(),YouTubeView.class);
i5.putExtra("value1","RIMsCCMy80E");
startActivity(i5);
Toast.makeText(getApplicationContext(),itemVal,Toast.LENGTH_SHORT).show();
break;
case 6:
Intent i6 = new Intent(getApplicationContext(),YouTubeView.class);
i6.putExtra("value1","LE5M3YYe_cE");
startActivity(i6);
Toast.makeText(getApplicationContext(),itemVal,Toast.LENGTH_SHORT).show();
break;
case 7:
Intent i7 = new Intent(getApplicationContext(),YouTubeView.class);
i7.putExtra("value1","yjpQ4qVd7Os");
startActivity(i7);
Toast.makeText(getApplicationContext(),itemVal,Toast.LENGTH_SHORT).show();
break;
default:
Toast.makeText(getApplicationContext(),"Sorry!!! There is no video",Toast.LENGTH_SHORT).show();
}
}
});
}
}
YouTubeView
package com.example.vinothvino.shortfilmy;
import android.os.Bundle;
import android.content.Intent;
import android.widget.Toast;
import com.google.android.youtube.player.YouTubeInitializationResult;
import com.google.android.youtube.player.YouTubePlayer;
import com.google.android.youtube.player.YouTubePlayerView;
import com.google.android.youtube.player.YouTubeBaseActivity;
import com.google.android.youtube.player.YouTubePlayer.Provider;
import com.google.android.youtube.player.YouTubePlayer.PlaybackEventListener;
import com.google.android.youtube.player.YouTubePlayer.PlayerStateChangeListener;
import com.google.android.youtube.player.YouTubeThumbnailLoader;
import com.google.android.youtube.player.YouTubeThumbnailView;
import com.google.android.youtube.player.YouTubeThumbnailLoader.ErrorReason;
public class YouTubeView extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener{
public static final int RECOVER_REQUEST = 1;
private YouTubePlayerView youTubeView;
private YouTubeThumbnailView youTubeThumbnailView;
private YouTubeThumbnailLoader youTubeThumbnailLoader;
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.youtube_view);
youTubeView = (YouTubePlayerView)findViewById(R.id.youtube_view);
youTubeView.initialize(Config.API_KEY,this);
}
public void onInitializationSuccess(Provider provider,YouTubePlayer player,boolean wasRestored) {
Bundle videoIdFromMainActiviy = getIntent().getExtras();
String videoID = videoIdFromMainActiviy.getString("value1");
player.setPlaybackEventListener(myPlaybackEvent);
player.setPlayerStateChangeListener(myPlayerState);
if (!wasRestored) {
player.cueVideo(videoID);
}
}
private PlaybackEventListener myPlaybackEvent = new PlaybackEventListener() {
@Override
public void onPlaying() {
Toast.makeText(getApplicationContext(),"Playing...",Toast.LENGTH_SHORT).show();
}
@Override
public void onPaused() {
Toast.makeText(getApplicationContext(),"Paused...",Toast.LENGTH_SHORT).show();
}
@Override
public void onStopped() {
Toast.makeText(getApplicationContext(),"Stopped...",Toast.LENGTH_SHORT).show();
}
@Override
public void onBuffering(boolean b) {
}
@Override
public void onSeekTo(int i) {
}
};
private PlayerStateChangeListener myPlayerState = new PlayerStateChangeListener() {
@Override
public void onLoading() {
Toast.makeText(getApplicationContext(),"Please be patient... ",Toast.LENGTH_SHORT).show();
}
@Override
public void onLoaded(String s) {
}
@Override
public void onAdStarted() {
Toast.makeText(getApplicationContext(),"Ayyayooo Add vandhuteyyy",Toast.LENGTH_LONG).show();
}
@Override
public void onVideoStarted() {
Toast.makeText(getApplicationContext(),"Video started",Toast.LENGTH_LONG).show();
}
@Override
public void onVideoEnded() {
Toast.makeText(getApplicationContext(),"See some other videos",Toast.LENGTH_LONG).show();
}
@Override
public void onError(YouTubePlayer.ErrorReason errorReason) {
}
};
public void onInitializationFailure(Provider provider,YouTubeInitializationResult errorReason){
if (errorReason.isUserRecoverableError()){
errorReason.getErrorDialog(this,RECOVER_REQUEST).show();
}else {
String error = String.format(getString(R.string.error), errorReason.toString());
Toast.makeText(this,error,Toast.LENGTH_LONG).show();
}
}
protected void onActivityResult(int requestcode, int resultcode, Intent data){
if (requestcode==RECOVER_REQUEST){
getYoutubePlayerProvider().initialize(Config.API_KEY,this);
}
}
protected Provider getYoutubePlayerProvider(){
return youTubeView;
}
}
Please help me.. Thanks in advanced
|
|
|
|
|