activity

android startActivity from intent in service [duplicate]

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This question already has an answer here: android start activity from service 6 answers i try to use intent in service but when i try this : Intent intent_facebook = new Intent (this,MainUploadToYoutube.class); intent_facebook.putExtra("vid", vid); startActivity(intent_facebook); got this error on logcat : Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? so i tried this from here : android start activity from service Intent intent_facebook = new Intent

Add Button on custom View in Android

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have the following class public class GameActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); View gameView = new GameView(this); setContentView(gameView); } } and now I'd like to add a Button to my class GameView. public GameView(Context context) { super(context); // Code ... } I need this button during my game, so it should be alywas in front of all the other canvas' I'm drawing. How can I do that? 回答1: Do you want to create a new button? Button b = new Button

Android Fragment Basics Tutorial

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: So I've been stuck on the third tutorial on the Android Developer Site about Fragments for few days. I just can't understand how the app populates data when I run the app on a tablet (big screen layout). I can understand how the data is being populated on a smaller screen (phone screen). How does the bigger screen list populate with data? Here is a link of the whole project from Android.com tutorials. MainActivity Class public class MainActivity extends FragmentActivity implements HeadlinesFragment.OnHeadlineSelectedListener { /** Called

ViewRootImpl.setPausedForTransition(boolean) NullPointerException in ActivityTransitionCoordinator when transition to other Activity invoked too early

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In my Android app, I have a splash screen where I do some setup and loading. My app uses default explode as a windowEnterTransition and a windowExitTransition and a changeImageTransform plus changeBounds transition set as a windowSharedElementEnterTransition and windowSharedElementExitTransition . For convenience, I start the next Activity using a static method where I pass the current Activity as a Context and a shared element. The code is provided in the second part of this post. One of the scenarios is that there is nothing to load, so

Android access activity method inside service

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How to call an Activity's non-static method from inside a service onStart()? 回答1: How to call an Activity's non-static method from inside a service onStart()? You can't. However, there are many ways to have a service communicate with a running activity, and I outline some of them here: How can I update information in an Android Activity from a background Service 回答2: This could help .. In activity define static MyActivity instance; then set value MyActivity.OnCreate instance = this; In your service MyActivity activity = MyActivity.instance;

How to fix The method startActivity(Intent) is undefined for the type new View.OnClickListener() syntax error

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a syntax errors with my code , in the "getView" I want to make a listener for the button "update" to move to another activity : @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater l = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE); View rowView = l.inflate(R.layout.temp, parent, false); TextView textView = (TextView) rowView.findViewById(R.id.textView1); ImageView imageView = (ImageView) rowView.findViewById(R.id.imageView1); Button update = (Button) rowView

FCM : onMessageReceived is not called,notification didn't came even after sending msg to fcm?

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i am developing an app where i want to implement FCM push notifications through php. So i made two java files: 1.FirebaseInstanceID (Working fine and getting token properly in database) 2.FirebaseMessagingSerivice (Not Called) My FirebaseMessagingService.java package com.example.xyz; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Intent; import android.support.v4.app.NotificationCompat; import com.google.firebase.messaging.RemoteMessage; public class FirebaseMessagingService extends com

When would Activity's instance die?

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Here is a sample code which make me a little missing: package com . leak ; import android . app . Activity ; import android . app . ProgressDialog ; import android . os . AsyncTask ; import android . os . Bundle ; public class WindowLeakActivity extends Activity { @Override protected void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ); new LeakThread (). execute (); } class LeakThread extends AsyncTask < Void , Void , Void >{ ProgressDialog dialog ; @Override protected void onPreExecute () { dialog

Start FragmentActivity from Activity

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How can I start a FragmentActivity from an Activity? My MainActivity is a splash screen and I want to star a FragmentActivity next. I need something instead of, for example: startActivity(new Intent("com.example.manager.MyFragmentActivity")); TIA. 回答1: From your first Activity call: startActivity(new Intent(this, MyFragmentActivity.class)); Note: Make sure to register your MyFragmentActivity in your AndroidManifest.xml . Edit: This training article on Starting Another Activity should be helpful to you. 文章来源: Start FragmentActivity from

How to preload an Activity?

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I searched everywhere for this but no one appears to have an answer. My simple question is: Is there a way to preload an activity? I need this because I use a tab,and a tab has multiple activities. One of my activities is a rss reader,and it loads pretty hard(about 2-3 seconds). All I found on the web is a joke.Everyone has an opinion,but no one can point you to a sample code. Waiting for an answer,thanks! This is the code that loads the feed: At onCreate: // go get our feed! feed = getFeed(RSSFEEDOFCHOICE); // display UI UpdateDisplay();