Coder Social home page Coder Social logo

generic_asynctask's Issues

Don't work in fragment

Hello, I have a small question, I tried this code in fragment but it gives me this error:
java.lang.ClassCastException: com.test.fragment1 cannot be cast to android.content.Context

Here is code which I used:

HashMap postData = new HashMap();
        postData.put("id", "1");

        PostResponseAsyncTask loginTask =
                new PostResponseAsyncTask(fragment1.this,postData);
        loginTask.execute("http://www.test.cz/removeUser.php");

What should I do?

Getting zero errors, but data result is null. I m applying in fragments.

Context context = container.getContext();
HashMap postData = new HashMap();
postData.put("mobile", "android");
postData.put("id", SaveSharedPreference.getId(this.getActivity()));
Log.d("imad","Chal raha ha 1");
PostResponseAsyncTask task = new PostResponseAsyncTask(context, postData, new AsyncResponse(){

            @Override
            public void processFinish(String result) {

                Log.d("imad","Chal raha ha 3");
                Log.d("imad", result + " wow");
            }
        }
        );
        task.execute("http://elandmania.com/agents/Android/get_customer1");

Problem when build signed apk

When I try to generate signed apk I get some erros. But when I build a debug aplication, it works.
I don't know if I'm doing something wrong or I forgot to set up something.

Warning:com.kosalgeek.genasync12.MainActivity: can't find referenced class com.kosalgeek.genasync12.R$layout

Warning:com.kosalgeek.genasync12.MainActivity: can't find referenced class com.kosalgeek.genasync12.R$id

Warning:com.kosalgeek.genasync12.MainActivity: can't find referenced class com.kosalgeek.genasync12.R$layout

Warning:com.kosalgeek.genasync12.MainActivity: can't find referenced class com.kosalgeek.genasync12.R$id

Warning:com.kosalgeek.genasync12.MainActivity: can't find referenced class com.kosalgeek.genasync12.R

Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.

Job failed, see logs for details

populating fragment list

Hello mr. Kosal,
First I want to thank you for all the videos you have been making, they helped me a lot. I followed your last video step by step but I'm getting an error that say's Error:(38, 94) error: incompatible types: SecondActivityListFragment cannot be converted to Context. Here is my fragment list class

 `
 public class SecondActivityListFragment extends ListFragment {

Communicator communicator;
private ArrayList<SubNote> subNotes;
private SubNoteAdapter subNoteAdapter;
private int[] productImages = {R.drawable.defualt_img, R.drawable.ad2, R.drawable.ad3};

@Override
public void onActivityCreated(Bundle savedInstanceState){
    super.onActivityCreated(savedInstanceState);

    ///https://www.youtube.com/watch?v=5v_1cqkFSuQ
    PostResponseAsyncTask taskread = new PostResponseAsyncTask(SecondActivityListFragment.this, new AsyncResponse() {
        @Override
        public void processFinish(String s) {

        }
    });
    taskread.execute("");

}

    @Override
    public void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);


    ItemViewFragment itemViewFragment = new ItemViewFragment();
    Bundle bundle=new Bundle();
    bundle.putInt("key", position);
    bundle.putString("name", subNotes.get(position).getTitle());
    bundle.putString("brief", subNotes.get(position).getBriefDescription());
    bundle.putString("full", subNotes.get(position).getFullDescription());
    bundle.putString("price", subNotes.get(position).getPrice().toString());
    bundle.putIntArray("images", subNotes.get(position).getProductImages());
    itemViewFragment.setArguments(bundle);

    FragmentManager fragmentManager = getFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.content_main, itemViewFragment,
            itemViewFragment.getTag()).commit();
}

@Override
public void onAttach(Context context) {
    super.onAttach(context);
    if (context instanceof Communicator) {
        communicator = (Communicator) context;
    } else {
        throw new RuntimeException(context.toString()
                + " must implement Communicator");
    }
}

}
`

Localhost

can i use asynctask with localhost? And if it can be used then what would be the parameter to readData.execute("");

Handle Internet disconnection

Hi, I need help in handling a disconnection of internet.
I need the app to retry sending the request after an interval of time.
Thanks in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.