android-intent

Restarting Android app programmatically

倖福魔咒の 提交于 2020-01-22 12:12:51
问题 This is a follow up question to this question: Force application to restart on first activity I am trying to restart my application from a fragment like that: Toast.makeText(getActivity(), "Restarting app", Toast.LENGTH_SHORT).show(); Intent i = getActivity().getBaseContext().getPackageManager() .getLaunchIntentForPackage(getActivity().getBaseContext().getPackageName() ); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); getActivity()

Restarting Android app programmatically

≡放荡痞女 提交于 2020-01-22 12:09:09
问题 This is a follow up question to this question: Force application to restart on first activity I am trying to restart my application from a fragment like that: Toast.makeText(getActivity(), "Restarting app", Toast.LENGTH_SHORT).show(); Intent i = getActivity().getBaseContext().getPackageManager() .getLaunchIntentForPackage(getActivity().getBaseContext().getPackageName() ); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); getActivity()

Passing File with intent, how do i retrieve it

时间秒杀一切 提交于 2020-01-22 09:29:30
问题 Here is what I am passing. pictureFile is a File Intent intent = new Intent (context, ShowPicActivity.class); intent.putExtra("picture", pictureFile); In the next activity which one of the getters do I use to get it? Intent intent = getIntent(); .....? 回答1: Try the following: YourPictureClass picture = (YourPictureClass)getIntent.getExtras().get("picture"); By calling getExtras() in your Intent you get an instance of Bundle . With the normal get() in class Bundle you can read every Object you

how to get file(pdf, jpg, docs) from local storage and create File [duplicate]

ぃ、小莉子 提交于 2020-01-22 03:30:10
问题 This question already has answers here : Android - Get real path of a .txt file selected from the file explorer (1 answer) onActivityResult's intent.getPath() doesn't give me the correct filename (1 answer) Getting the Absolute File Path from Content URI for searched images (2 answers) Create a file from a photo URI on Android (1 answer) Closed 3 months ago . I tried to create file with intent data uri To create File, I start intent like this val intent = Intent(Intent.ACTION_GET_CONTENT)

Android if and else if statement not working

风格不统一 提交于 2020-01-22 03:08:29
问题 I'm trying to use the following code to show one intent if the record count is = too or greater then 5 and a different intent if the record count is less then 5 on the first button of a dashboard layout. But I keep getting the evil NullPointError..........Am I on the right track or am I flapping in the wind, please help and point out what i'm doing wrong...Thanks private class DashboardClickListener implements OnClickListener { // @Override public void onClick(View v) { Intent i = null;

How to have an activity that will run once only? [duplicate]

跟風遠走 提交于 2020-01-22 02:30:08
问题 This question already has an answer here : Closed 8 years ago . Possible Duplicate: How do I show an alert dialog only on the first run of my application? In my app there will be a Terms and Conditions activity which shows some conditions along with ok and cancel buttons, and when the user presses 'ok' button the app continue and go on running. Next time when the user starts this app the Terms and Conditions activity must not run as its already accepted before. How to get such a functionality

passing JSON object to another activity on list item click

只愿长相守 提交于 2020-01-22 02:27:09
问题 I have a scenario here,i want to pass the desired json object on the list item click in my below activity suppose when i click deal 2 2nd json object from jArray should be passed to intent and my next activity must get it. but problem here is that when i click any of the list items the next activity receives json object at last index . here is my code from alldeals.java try{ jArray = new JSONArray(result); for(int i=0;i<jArray.length();i++){ json_data = jArray.getJSONObject(i); Log.i("log_tag

Want to display data in Indian Regional language(Telugu,Hindi,Tamil and Malayalam) from RSSFeed in android? [closed]

让人想犯罪 __ 提交于 2020-01-21 12:08:39
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I am developing an application for newspaper. I want to get the data from a RSSfeed and I want to display the data in a ListView manner with Regional Languages. How can this be done in android? 回答1: You need to

Empty intent extras in onActivityResult

强颜欢笑 提交于 2020-01-21 08:53:06
问题 I have two activities. First calls second like this: Intent intent = new Intent(this, Second.class); startActivityForResult(intent, 1); returning data in second one: Intent intent = new Intent(); intent.putExtra("a", "la-la-la"); setResult(RESULT_OK, intent); finish(); and trying to receive this data in first activity: @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if ((resultCode == Activity

NullPointerException On Android.os.Bundle

荒凉一梦 提交于 2020-01-20 05:19:09
问题 I have some problem with my code, when I need to transfer some data from one Activity to another one. First Activity ( ViewCashflow ) and I want transfer some data from ViewCashflow to second Activity ( NewTransaction ). Here its working well with no error, the data transferred successfully. But, I don't know what's going on when I run the second Activity directly (not from first Activity like before when I transfer the data) I got null pointer exception on the method that I use to receive