android-activity

How to call an activity from a Dialogfragment in android?

泪湿孤枕 提交于 2019-12-25 18:29:05
问题 I want to call an activity from Dialogfragment, I have attached the code and logcat below for your reference on what I have tried.Kindly provide me your knowledge on it. Thank you. Intent intent = new Intent(getActivity(), LinkActivity.class); getActivity().startActivityForResult(intent, 0); Logcat: 02-12 13:47:17.345: E/AndroidRuntime(670): FATAL EXCEPTION: main 02-12 13:47:17.345: E/AndroidRuntime(670): java.lang.NullPointerException 02-12 13:47:17.345: E/AndroidRuntime(670): at android

Android - Request code in onCreate [closed]

女生的网名这么多〃 提交于 2019-12-25 18:27:52
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago . can I access the requestCode an activity received in its onCreate() method? I'd need it to understand if it is a "new" or "modify" operation. 回答1: Let's say you create an activity A : The activity lifecycle goes like this : A.onCreate() -> A.onStart() -> A.onResume() Then you call activity B from

java, android: onActivityResult with different parameters in one activity

有些话、适合烂在心里 提交于 2019-12-25 18:21:19
问题 I have one activity where i use two onActvityResults one for the CalendarView : @Override protected void onActivityResult(int requestCode, int responseCode, Intent intent) one for the retrieving of events in Google Calendar: @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) How do i have these two in one activity? Thanks! 回答1: It seems you have not properly understood the concept! This might help you to understand onActivityResult . By using

httpGet Request error

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-25 18:16:34
问题 I would like to get returned value from my webservice. I have my class wich Manages the HTTPRequest: public class RatePromotions { public RatePromotions() {} public String executeHttpGet(String url) throws Exception { BufferedReader in = null; try { HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(); request.setURI(new URI(url)); HttpResponse response = client.execute(request); in = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));

How to keep an activity alive while closing all the others in android?

心不动则不痛 提交于 2019-12-25 17:47:29
问题 I have a main activity that contains a drawer and then i have other activities that opens on top of it they also have the drawer menu(they inherit main activity) public class OBDActivity extends MainActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LayoutInflater inflater = (LayoutInflater) this.getSystemService(getApplicationContext().LAYOUT_INFLATER_SERVICE); View contentView = inflater.inflate(R.layout.activity_setting, null,

An error occured while executing doInBackground(). FATAL EXCEPTION:AsyncTask #10 [duplicate]

a 夏天 提交于 2019-12-25 17:44:24
问题 This question already has answers here : How to fix 'android.os.NetworkOnMainThreadException'? (55 answers) Closed 5 years ago . On the click event add data to MySQL database through php on the localhost. Its showing following logcat error on the click event. Please help me to solve this problem. 08-11 07:31:06.416: D/gralloc_goldfish(971): Emulator without GPU emulation detected. 08-11 07:31:53.377: D/Inside Click(971): aaaaaaa 08-11 07:31:53.837: D/inid doinbackground(971): aaaaaaa 08-11 07

Error inflating class Recycler View

岁酱吖の 提交于 2019-12-25 16:55:33
问题 I am a beginner in Android and trying to learn the Recycler View using this simple example.But I am getting the exception as seen in the Logcat.I have included all the necessary support libraries and added them to the build path of the project. Following are my files related to the recycler view: Logcat: Could not find class android.support.v7.widget.RecyclerView', referenced from method com.example.rtest.MainActivity.onCreate 10-27 23:36:14.480: E/AndroidRuntime(12806): FATAL EXCEPTION: main

Error inflating class Recycler View

纵饮孤独 提交于 2019-12-25 16:55:25
问题 I am a beginner in Android and trying to learn the Recycler View using this simple example.But I am getting the exception as seen in the Logcat.I have included all the necessary support libraries and added them to the build path of the project. Following are my files related to the recycler view: Logcat: Could not find class android.support.v7.widget.RecyclerView', referenced from method com.example.rtest.MainActivity.onCreate 10-27 23:36:14.480: E/AndroidRuntime(12806): FATAL EXCEPTION: main

Keep activity alive in background until user doesn't kill or close app?

此生再无相见时 提交于 2019-12-25 16:55:06
问题 Can I keep Android activity alive in background, until user doesn't kill or close the application. I want to detect user clicks in background some specific hardware button clicks, as onKeyDown is not available in service, I need to keep my activity alive in background until user kills the app. Does android allows such behavior ? Update : I was able to solve this using following approach : 1] Use foreground service, Ref : https://developer.android.com/guide/components/services.html#Foreground

Using imageButtons to switch activities. How can I switch image in second activity based on button pressed?

时间秒杀一切 提交于 2019-12-25 16:23:37
问题 I am just starting to dabble with Android development. Right now, I have a program in Android Studio that has two columns of images about 6 images each. I want to make it so if I click that image, it will appear in the new activity. Right now, I am just loading the layout like this: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); String name = intent.getStringExtra(Main.CHAMPION_NAME); setContentView(R.layout.activity