android-activity

How to exit current activity to homescreen (without using “Home” button)?

╄→尐↘猪︶ㄣ 提交于 2020-01-02 22:31:54
问题 I am sure this will have been answered but I proved unable to find it. So please excuse my redundancy. What I am trying to do is emulating the "Home" button which takes one back to Android's homescreen. So here is what causes me problems: I have 3 launcher activities. The first one (which is connected to the homescreen icon) is just a (password protected) configuration activity. It will not be used by the user (just admin) One of the other 2 (both accessed via an app widget) is a

Using Intents as a form of message passing

六月ゝ 毕业季﹏ 提交于 2020-01-02 21:54:09
问题 Are there any drawbacks to using intents as a form of message passing between two apps that I control? I have two apks which will always exist on the device together. And, I'd like to use explicit intents to pass messages back and forth as opposed to creating and managing two separate services. Using explicit intents just seems like an easier to manage approach than services. 回答1: Communication between applications can expose certain rich, but if you really need to do this way, you can only

Start Activity of Main project from my library project

陌路散爱 提交于 2020-01-02 17:54:14
问题 I have 2 projects. One is my Main Project(A) , and another is a Library Project(B). I want to start an activity which is present in A from an activity which is located in B. How do I do that ? I Tried startActivity(getApplicationContext(),B.class); ,but B.class is not resolved. How Can I let my library project start an activity of my main project ? 回答1: You can add custom Action in intent-filter of you activity and start that activity by specifying action <activity android:name="my.package

Hide NFC app from “Choose Application” list / Disable start by external NFC intent

折月煮酒 提交于 2020-01-02 15:26:24
问题 I'm currently writing a couple of NFC enabled apps for Android and wanted to know how I can stop my application from being in the "choose application" list that's opened whenever a tag is scanned from the launcher or a non-NFC app. I only want my apps to be able to read the tags when they are open. My current intent filters: <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> <action

getActivity() with in FragmentActivity: android

不问归期 提交于 2020-01-02 11:43:14
问题 I am using this class A which extends another abstract class (and this abstract class extends FragmentActivity) and in one of my function with in A class I want to get getActivity() for my current activity A. But whenever I use getActivity , It gives me error that getActivity() method is not defined type for my class. Please help me !! How can I achieve this?? Code for my class A public class A extends B { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState)

Abstract class to get rid of redundant code in activities

主宰稳场 提交于 2020-01-02 08:55:12
问题 I created an abstract class to prevent redundant code in each of my activities. public abstract class MyGeneralizedActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } @Override public void attachBaseContext(Context newBase) { super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase)); } //... } I was perfectly fine by doing this: public class

Handle app closing event from Launcher's menu

纵然是瞬间 提交于 2020-01-02 07:49:48
问题 What I want to do is to know when user closes the app from Android Launcher's menu, which gets opened on home button long click: I want to do some operations when user closes the app. Actually, I want user to logout each time he leaves the app, but as long as he can close app in this was too, I have to handle this event and then make my operations. I've tried to google this one, but I couldn't find anything considering this. I don't want to override onStop() or onDestroy(), as long as the

Unable to implement callback in Android

微笑、不失礼 提交于 2020-01-02 07:49:07
问题 I am building an SDK. The Scenario From the app, the developer passes the JsonObject and URL in a method and inside the SDK. I add those values in SQLite database and start a JobScheduler. The Jobscheduler takes the request at 0 indexes out of the database executes it. When I get the response, I delete that request from the database and now the request at 1 index comes to the 0 index and again I execute the same code where 0th index request is fired. The Problem When I get the response from a

How to pass data between activities using static variables on a public class?

久未见 提交于 2020-01-02 07:18:49
问题 I'm trying to use static variables on a public class for passing them between activities. I'm having a rare problem doing that. I'm giving values to the static variables on a activity. This activity calls a GLSurfaceView and listen for screen orientation changes. If i give values to the static variables on the GLSurfaceView, then, all works fine, the values are stored and i can retrieve them when the onCreate method is called again after a screen orientation change. The problem is when i

How do I start another application (downloaded or preinstalled) from an activity?

℡╲_俬逩灬. 提交于 2020-01-02 07:17:13
问题 Basically, I want to get a list of all installed apps and pick one to run from an activity. I've tried ACTION_PICK with Intents but that seems to leave out apps that were downloaded and it has a bunch of junk in it. Thanks 回答1: // to get the list of apps you can launch Intent intent = new Intent(ACTION_MAIN); intent.addCategory(CATEGORY_LAUNCHER); List<ResolveInfo> infos = getPackageManager().queryIntentActivities(intent, 0); // resolveInfo.activityInfo.packageName = packageName //