Runtime error: stop before resume with recycleview - android

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);
}

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

Related

Getting an error android.util.SuperNotCalledException: Activity {} did not call through to super.onCreate()

I'm making a TV that plays music and youtube videos. I get the following error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.newapp, PID: 12965
android.util.SuperNotCalledException: Activity {com.example.newapp/com.example.newapp.YoutubeActivity} did not call through to super.onCreate()
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3081)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3237)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:81)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1929)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:209)
at android.app.ActivityThread.main(ActivityThread.java:7021)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:486)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:872)
This is my code for the youtube activity
public class YoutubeActivity extends YouTubeBaseActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
Log.e("youtube", "onCreate");
super.onCreate(savedInstanceState);
setContentView(R.layout.youtube_main);
setupVideoPlayer();
}
And this is the code (in another file) that initializes the Activity
private final class ItemViewClickedListener implements OnItemViewClickedListener {
#Override
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
RowPresenter.ViewHolder rowViewHolder, Row row) {
if (item instanceof Radio) {
Radio radio = (Radio) item;
Log.d(TAG, "RadioItem: " + item.toString());
System.out.println(getActivity());
Intent intent = new Intent(getActivity(), DetailsActivity.class);
intent.putExtra(DetailsActivity.RADIO, radio);
Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(
getActivity(),
((ImageCardView) itemViewHolder.view).getMainImageView(),
DetailsActivity.SHARED_ELEMENT_NAME)
.toBundle();
getActivity().startActivity(intent, bundle);
} else if (item instanceof Video) {
Video video = (Video) item;
Log.e(TAG, "VideoItem: " + item.toString());
System.out.println(getActivity());
Intent intent = new Intent(getActivity(), YoutubeActivity.class);
intent.putExtra(YoutubeActivity.VIDEO, video);
Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(
getActivity(),
((ImageCardView) itemViewHolder.view).getMainImageView(),
YoutubeActivity.SHARED_ELEMENT_NAME)
.toBundle();
getActivity().startActivity(intent, bundle);
}
else if (item instanceof String) {
if (((String) item).contains(getString(R.string.error_fragment))) {
Intent intent = new Intent(getActivity(), BrowseErrorActivity.class);
startActivity(intent);
} else {
Toast.makeText(getActivity(), ((String) item), Toast.LENGTH_SHORT).show();
}
}
}
}
As you can see, if the item clicked is a radio, then it goes to another activity that plays the radio. This works perfectly. But if the item clicked is a video, it goes to the youtube player activity, which gives the exception given in the first code block.
In addition, you can see that I have the super.OnCreate() function, so I am unsure where I'm messing up.
Please be sure YouTubeBaseActivity has the super.onCreate() method inside the onCreate event.
So I got it to work, not by conventional methods though. I just made a new project and copied over the old one to the new. Still not sure what was going wrong but it's working now.

Rock,Paper,Scissors progress of the game in app

so I want to create a Rock Paper Scissors app that should work like this:
In the first screen you enter the names of the 2 players.
In the second screen there are the names of the players and the score of each player near it.The progress is that you need to click a button,and after you click it,in each player's side,random image(rock paper or scissors) will appear and the winner will get a point,or nobody will if its a draw.
NOTE:This might not be an error in the code based on what i've seen when I tried to search for the message i'm getting while debugging so you may want to look at it first.
I would appreciate some comments on the code though.
I checked if the names that i'm passing from the first activity to the second one before I had started to work on the button and the app worked fine.
But after I wrote the code for the OnClickListener, the app just crashes instantly after the first activity when I run it. It is my first time working with images like that so i'm not sure that if used it properly. I have created some functions so the code will be more readable without knowing exactly what i'm doing though because i'm pretty new to android.
first activity:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button startBtn;
startBtn = findViewById(R.id.startBtn);
startBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
EditText p2Name=findViewById(R.id.p2EditText);
EditText p1Name=findViewById(R.id.p1EditText);
String name1=p2Name.getText().toString();
String name2=p1Name.getText().toString();
Intent intent1 = new Intent(MainActivity.this, Game.class);
intent1.putExtra("name1",name1);
intent1.putExtra("name2",name2);
MainActivity.this.startActivity(intent1);
}
});
}
second activity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game);
String p1Name;
String p2Name;
if (getIntent().hasExtra("name1")) {
p1Name = getIntent().getStringExtra("name1");
TextView p1NView = findViewById(R.id.p1);
p1NView.setText(p1Name);
}
if (getIntent().hasExtra("name2")) {
p2Name = getIntent().getStringExtra("name2");
TextView p2NView = findViewById(R.id.p2);
p2NView.setText(p2Name);
}
Button NRound=findViewById(R.id.newRoundBtn);
NRound.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
TextView score1=findViewById(R.id.score1View);
TextView score2=findViewById(R.id.score2View);
int p1Score = Integer.parseInt(score1.getText().toString());
int p2Score = Integer.parseInt(score2.getText().toString());
String[] RPS = new String[]{"rock", "paper", "scissors"};
Random r = new Random();
String p1Hand;
String p2Hand;
p1Hand = RPS[r.nextInt(3)];
p2Hand = RPS[r.nextInt(3)];
showImages(p1Hand,p2Hand);
String result=findWinner(p1Hand,p2Hand);
switch (result){
case "player1":
p1Score++;
score1.setText(String.valueOf(p1Score));
case "player2":
p2Score++;
score2.setText(String.valueOf(p2Score));
if(score1.getText().equals('3') || score2.getText().equals('3')){
Intent end=new Intent(Game.this,EndScreen.class);
Game.this.startActivity(end);
}
}
}
});
update();
}
public static String findWinner(String hand1,String hand2){
if(hand1.equals(hand2)){
return "draw";
}
String both=hand1.concat(hand2);
if(both.equals("rockscissor") || both.equals("paperrock")||both.equals("scissorspaper")){
return "player1";
}else{
return "player2";
}
}
public void showImages(String hand1,String hand2){
ImageView rock1=findViewById(R.id.rock1);
ImageView paper1=findViewById(R.id.paper1);
ImageView scissors1=findViewById(R.id.scissors1);
ImageView rock2=findViewById(R.id.rock2);
ImageView paper2=findViewById(R.id.paper2);
ImageView scissors2=findViewById(R.id.scissors2);
switch (hand1){
case "rock":
rock1.setVisibility(View.VISIBLE);
case "paper":
paper1.setVisibility(View.VISIBLE);
case "scissors":
scissors1.setVisibility(View.VISIBLE);
}
switch (hand2){
case "rock":
rock2.setVisibility(View.VISIBLE);
case "paper":
paper2.setVisibility(View.VISIBLE);
case "scissors":
scissors2.setVisibility(View.VISIBLE);
}
}
public void update(){
ImageView[] images=new ImageView[6];
for (ImageView image:images)
{
if(image.getVisibility()==View.VISIBLE){
image.setVisibility(View.GONE);
}
}
}
Logs
Edit:now after I have posted and seen the logs I understood what was the problem. I forgot to initialize the imageView array in a function and I was just looping over null array,trying to get its visibility.And Now it does not crash.
I didn't know about this so thanks anyways for telling me to post it.(thought errors should show up in the console or something).
Now I am dealing with another problem,I will try to solve it on my own though.
Process: com.example.rockpaperscissors, PID: 11607
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.rockpaperscissors/com.example.rockpaperscissors.Game}: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.widget.ImageView.getVisibility()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3260)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3396)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2009)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7319)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:934)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.widget.ImageView.getVisibility()' on a null object reference
at com.example.rockpaperscissors.Game.update(Game.java:71)
at com.example.rockpaperscissors.Game.onCreate(Game.java:65)
at android.app.Activity.performCreate(Activity.java:7783)
at android.app.Activity.performCreate(Activity.java:7772)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3235)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3396) 
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) 
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2009) 
at android.os.Handler.dispatchMessage(Handler.java:107) 
at android.os.Looper.loop(Looper.java:214) 
at android.app.ActivityThread.main(ActivityThread.java:7319) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:934) 
I tried to debug the app and at the last line of the first activity,the message that shows up is: source code does not match the byte code.
First try to clean the project and rebuild it.
In order for us to help you with the crash, we need to see the logs. Please add that as well.
About your code:
MainActivity.class
Try validating user input before passing it to the next activity.
Game.class (assuming this is also an activity so try renaming it to GameActivity.class)
When you are retrieving data from the intent, it's best practice to create a constant and make it public that you can use in the main activity as well (if you make a typo, it's hard to find the problem)
Something like: public static final String NAME_ONE_KEY = "name1";
I don't see the need of using a string array, identify those actions by integer and comment it so you and others who read your code can understand it.
It seems like you have a lot of child elements in your game layout file
Add the images into the drawable folder, create one image view for each player and update the image source.
Finally, save the state so you don't loose the data on device rotation.

Activity started from service visibility null

i am trying to have an activity launched from a service.
My problem is hiding/showing this activity.
The activity is started like so
overlay = new BubbleOverlay();
Intent intent = new Intent(this, overlay.getClass()).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Activity:
public class BubbleOverlay extends Activity {
private boolean active = false;
private View mainView;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.overlay_layout);
mainView = findViewById(R.id.main_overlay_layout);
if(mainView == null)
Log.d("BubbleOverlay", "onCreate: MainView is null");
}
public void setActive(boolean value){
active = value;
}
public void hide(){
active = false;
mainView.setVisibility(View.INVISIBLE);
}
public void show(){
active = true;
mainView.setVisibility(View.VISIBLE);
}
I am trying to toggle the visibility of the mainView from the service.
Handler handler = new Handler();
Runnable runnable_longClick = new Runnable() {
#Override
public void run() {
// TODO Auto-generated method stub
overlay.hide();
}
};
handler.postDelayed(runnable_longClick, 5000);
this produces the following error:
07-28 05:51:56.549 21690-21690/com.derp.derp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.derp.derp, PID: 21690
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setVisibility(int)' on a null object reference
at com.derp.derp.BubbleOverlay.hide(BubbleOverlay.java:37)
at com.derp.derp.BubbleService$4.run(BubbleService.java:181)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6044)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
The reason you're getting the Null Pointer Exception is the mainView has not been initialised before its use. This happens because the Activity's onCreate() method which holds the object's initialise statement has not been called (with respect to the overlay object you created inside your Service). The onCreate() method will only be called once the Activity is created.
In order to call the hide() method of the Activity from the Service you need to create a proper communication channel between the Activity and the Service i.e. you need to bind the Service to your Activity. I know, this approach requires a bit of coding efforts but its the best approach and it will guarantee you flawless and smooth functioning for your app.

ActivityNotFoundException, error starting an activity

This is my social fragment activity and it contains buttons view. when i click on it i want to switch from one activity to other but when i lauch it on phone and click on button it says "unfortunately app stopped" what should i do to switch from one fragment to other fragment.
here is my social frag code:
SocialFrag
and i want to switch from social fragment to TechGadget Fragment on button click.
Here is Log cat
Log Cat
my App contains navigation drawer with tabhlayout and i declared buttons in one tab...while i want to open new activity when button gets clicked.
**#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.social_layout,container,false);
b = (Button) rootView.findViewById(R.id.button2);
b.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent i = new Intent(getActivity().getApplicationContext(),TechGadgets.class);
startActivity(i);
}
});
return rootView;
}
}**
it reutrns error and here is log cat
04-28 01:07:07.300 17089-17089/com.example.android.techfnss E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.techfnss, PID: 17089
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.android.techfnss/com.example.android.techfnss.TechGadgets}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1885)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1579)
at android.app.Activity.startActivityForResult(Activity.java:3934)
at android.app.Activity.startActivityForResult(Activity.java:3894)
at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:849)
at android.support.v4.app.FragmentActivity$HostCallbacks.onStartActivityFromFragment(FragmentActivity.java:907)
at android.support.v4.app.Fragment.startActivity(Fragment.java:916)
at com.example.android.techfnss.SocialFragment$1.onClick(SocialFragment.java:26)
at android.view.View.performClick(View.java:5207)
at android.view.View$PerformClick.run(View.java:21168)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-28 01:07:10.275 17089-17089/com.example.android.techfnss I/Process: Sending signal. PID: 17089 SIG: 9
This question has been asked tens of times (at least), so you could've found an answer by a Google search. However, here is how you do it...
Button button = (Button) findViewById(R.id.my_button);
button.setOnClickListener() {
#Override
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this, SecondActivity.class);
startActivity(intent);
}
};
Of course you would replace the relevant values with corresponding ones in your own code.
If you're looking for a more specific answer, ask a more specific question (with evidence that you have done research to find the answer yourself, or even at least a log trace from the crash you are getting).
You need to add setOnClickListener on your button inside onViewCreated method, like this --
public void onViewCreated(View view, Bundle savedInstanceState){
b = (Button)view.findViewById(R.id.button2);
b.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent intent = new Intent(getContext(), 2nd_Activity.class);
startActivity(intent);
}
});
}
Hope this helps!
use this code -
Intent intent = new Intent(MainActivity.this, OtherActivity.class);
startActivity(intent);
here, OtherActivity.class is the name of activity that you want to go,and Mainactivity.this is your current activity.
You can pass the context to the Fragment when you create it and then reference it there. Or you can just use getActivity() instead of getActivity().getApplicationContext() but the first option is the best because sometimes getActivity() just doesn't work.
Always pass the context to the fragment.
Clearly it says that the activity is not declared in the manifest, instead of extend fragment, extend to any type of activity and add this line to your manifest inside the <aplication> </aplication> body:
<activity android:name=".TechGadgets"></activity>
Example:
<aplication>
...
<activity android:name=".TechGadgets"></activity>
...
</application>
And close this ask please
try using the below code
Intent intent = new Intent(MainActivity.this, SecondActivity.class);
startActivity(intent);
and also check did you added activity in manifest
<activity android:name=".TechGadgets"></activity>

textView.setText() Error - Android

I am aware there are many forms on StackOverflow about this very topic but none of the fixed worked for me.
When I run the code:
muteText.setText("Testing")
I get an error.
MainActivity.java
//Class Variables
Button startTime;
Button endTime;
TextView muteTime;
TextView unmuteTime;
int hour;
int minute;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Define Variables
startTime = (Button)findViewById(R.id.startButton);
endTime = (Button)findViewById(R.id.endTime);
muteTime = (TextView)findViewById(R.id.muteText);
Log.i("SchedMute", "muteTime: " + muteTime.getText().toString());
unmuteTime = (TextView)findViewById(R.id.unmuteTime);
//Button Listeners
startTime.setOnClickListener(this);
endTime.setOnClickListener(this);
//--\\
hour = 0;
minute = 0;
}
public void onClick(View v){
int id = v.getId();
if(id == R.id.startButton){ //Selecting time 2 Mute phone
showTimePickerDialog(v);
}
}
public void setStartTime(){
muteTime.setText("Testing Testing 123");
}
(Error occurs in last Method (setStartTime))
I am calling the method in another class by doing so:
MainActivity activity = new MainActivity();
activity.setStartTime();
I spend a good 30 minutes trying to figure this one out.
Error:
07-29 12:29:44.034 19958-19958/myApp.com.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: myApp.com.app, PID: 19958
java.lang.NullPointerException
at myApp.com.app.MainActivity$TimePickerFragment.onTimeSet(MainActivity.java:96)
at android.app.TimePickerDialog.tryNotifyTimeSet(TimePickerDialog.java:223)
at android.app.TimePickerDialog.onClick(TimePickerDialog.java:173)
at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:170)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5678)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
at dalvik.system.NativeStart.main(Native Method)
MainActivity activity = new MainActivity();
You can NOT correctly create an instance of an Activity by using new. Never attempt to do this, it will not give you the behaviour you expected.
If you need to call a method in an Activity from a Fragment that is attached to it, you should used the approved approach of using a 'callbacks' interface.
See the following for Communicating with Other Fragments - even though it is about communicating with other Fragments, it is also the way a Fragment should communicate with the Activity it is attached to.
You call to setText before the Activity finished it creation. You need to call the function from the new Activity onCreate().
You should never call the constructor of an Activity. If you do, none of its activity lifecycle will occur. I'm guessing you're doing that in the time picker dialog, you should make that activity be a listener (or pass in an anonymous inner class listener) to handle the set time.

Categories

Resources