i have a class TenantDetailsListAdapter
details that extends BaseAdapter
as
public class TenantDetailsListAdapter extends BaseAdapter {
}
i am trying to start an intent activity insite the class but it is not working.
My intent is as follows :
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:+"+text1 .trim()));
startActivity(callIntent);
can someone know how to call an activity which is not in an activity extends.
Do something like this in your BaseAdapter
:
private Context _mContext;
public MyBaseAdapter(Context context/* some other data you need */){
this._mContext = context;
}
@Override
public View getView(int position, View convertView, ViewGroup parent){
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:+"+text1 .trim()));
calIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // you are starting intent out of the activity so you will need this.
_mContext.startActivity(callIntent);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.