0

i am trying to put a list in my app with a listener on each element where clicking on it opens a new activity with a parameter given by the field. It sounds quite easy but as i moved from listview to recyclerview i am facing an error

The first time i click on an item, and only the first one, it takes 5/6 seconds to open and throws an exception like the following

RuntimeException: Performing stop of activity that is not resumed

on the activity that keeps the list

This is the code i am using to set up the listener in the viewholder

public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

    private final AdapterRequestListController controller;
    // each data item is just a string in this case
    public TextView elapsedTime;
    public View rootView;

    public ViewHolder(View v, AdapterRequestListController controller) {
        super(v);
        elapsedTime = (TextView) v.findViewById(R.id.rlr_reply_title);
        rootView = v;
        this.controller = controller;
        v.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        controller.openReply(getAdapterPosition());
    }
}

I looked for the problem in the controller (that is actually my activity) but nothing changed, ao i moved to the adapter and the very strange thing is that if i put the listener in the onbind method of the adapter it does not happen

I don't like to put it there for many reasons (tons of listener updated every time it scrolls)

Any suggestions or ideas? Thanks!


This is the complete exception

E/ActivityThread: Performing stop of activity that is not resumed: {it.mb.s/it.mb.s.working.ActivityVI}

java.lang.RuntimeException: Performing stop of activity that is not resumed: {it.mb.s/it.mb.s.working.ActivityVI}
                                                                            at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3465)
                                                                            at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3550)
                                                                            at android.app.ActivityThread.-wrap20(ActivityThread.java)
                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1373)
                                                                            at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                            at android.os.Looper.loop(Looper.java:148)
                                                                            at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                            at java.lang.reflect.Method.invoke(Native Method)
                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

UPDATE 2

this is the method that actually runs the intent

@Override
public void openReply(int position) {
    //TODO
    Log.d(TAG, position + " fired");

    Intent intent = new Intent(this, ActivityViewReply.class);
    Bundle bundle = new Bundle();
    bundle.putSerializable(ActivityViewReply.REQUEST_FIELD_NAME, meRequests.get(position));
    intent.putExtras(bundle);
    startActivity(intent);

}
il.bert
  • 232
  • 1
  • 3
  • 11
  • Please show how your whole stack trace. – barq Mar 03 '16 at 07:26
  • I updated the question with the full stack – il.bert Mar 12 '16 at 18:33
  • Are you starting the same activity on that click event? – Phyrum Tea Mar 12 '16 at 18:59
  • no i am moving from ActivityVI to ActivityViewReply, I just checked twice in the code and it is correct, I add it in the text – il.bert Mar 12 '16 at 19:29
  • Difficult to see what's causing the problem. Are you sure, it's in the startActivity? Maybe some problem in the putSerializable? – Phyrum Tea Mar 12 '16 at 20:14
  • No, that is working, I also tried launching an empty activity and the same happened, so the problem is in the launching activity. The structure I have is an activity with a navigationDrawer and many fragment, in one of them i have a recyclerview with the listener that calls the parent activity which actually starts the new one – il.bert Mar 13 '16 at 07:17

1 Answers1

0

Try flag for your intent .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);