Я не могу запустить операцию с моего адаптера просмотра переработчика. Я sh, чтобы загрузить PDF-файл с FireBase. Я видел несколько постов, в которых упоминается прохождение контекста, но я сделал это. Я также проверил, передается ли контекст с помощью оператора if и выполняется ли условие if. Я не знаю, в чем причина этой ошибки.
Это мой код адаптера
public class NotesAdapter extends RecyclerView.Adapter<NotesAdapter.ViewHolder> {
private Context context;
private ArrayList<Upload> noteslist;
private Downloader downloader;
public static final String TAG = "NotesAdapter";
public NotesAdapter(Context context, ArrayList<Upload> noteslist) {
this.context = context;
this.noteslist = noteslist;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_notes,parent,false);
return new NotesAdapter.ViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
final Upload notes = noteslist.get(position);
holder.title.setText(notes.getName());
holder.author.setText(notes.getAuthor());
holder.noOfDown.setText("No. of Downloads = "+String.valueOf(notes.getDownload()));
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(context instanceof DownloadNotes) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(notes.getUrl()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent); <-------Error
}
}
});
}
@Override
public int getItemCount() {
return noteslist.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
TextView title,author,noOfDown;
View view ;
public ViewHolder(@NonNull View itemView) {
super(itemView);
title = itemView.findViewById(R.id.title);
author = itemView.findViewById(R.id.authorname);
noOfDown = itemView.findViewById(R.id.download);
this.view=itemView;
}
}
Это ошибка, которую я получаю
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.collegeconnect, PID: 32314
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=com.google.android.gms.tasks.zzu@ab761b0 flg=0x10000000 }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2007)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1673)
at android.app.Activity.startActivityForResult(Activity.java:4586)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:675)
at android.app.Activity.startActivityForResult(Activity.java:4544)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:662)
at android.app.Activity.startActivity(Activity.java:4905)
at android.app.Activity.startActivity(Activity.java:4873)
at com.example.collegeconnect.NotesAdapter$1.onClick(NotesAdapter.java:72)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)