activity

How one interface can be used for different background android tasks?

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Well, I have an activity class with two background task (Async-Task) which have been defined in two separate classes like public class GettingBeaconsList extends AsyncTask public class GettingAirports extends AsyncTask which are initialized and executed in MainClass public class MainClass extends Activity implements DelegateTaskCompleted { int ServiceBoolean = 0; public OnClickListener LoadingBeaconList = new OnClickListener() { public void onClick(View v) { ServiceBoolean =1; new GettingBeaconsList (context,MainClass.this).execute(); } }

Start android service from Unity3D code

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In my Unity3D application for android I need to start a service, which will run in background. I can't figure it out how can I do it. The method startService() has to be invoked on an activity, but I do not know how to pass the current unity activity from unity script to my android plugin. And I haven't found any way to get the activity in a static method and run startService() in it. As far as I understand the sequence, I need to get main Unity3D activity and start the service from it. My class which is supposed to call the service. public

Automating Hive Activity using aws

匿名 (未验证) 提交于 2019-12-03 07:36:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I would like to automate my hive script every day , in order to do that i have an option which is data pipeline. But the problem is there that i am exporting data from dynamo-db to s3 and with a hive script i am manipulating this data. I am giving this input and output in hive-script that's where the problem starts because a hive-activity has to have input and output but i have to give them in script file. I am trying to find a way to automate this hive-script and waiting for some ideas ? Cheers, 回答1: You can disable staging on Hive Activity

Getting W/Activity: Can reqeust only one set of permissions at a time

匿名 (未验证) 提交于 2019-12-03 07:36:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I made an app that have a request for camera and GPS, but whem I execute I am getting this Warm several times with less them 1 sec of each other. W/Activity: Can reqeust only one set of permissions at a time) Can some one tell me why? @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); mStatusCamera = intent.getStringExtra("camera"); mScannerView = new ZXingScannerView(this) { @Override protected IViewFinder createViewFinderView(Context context) { return new

Warning: Do not place Android context classes in static fields; this is a memory leak (and also breaks Instant Run)

匿名 (未验证) 提交于 2019-12-03 07:36:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Android Studio: Do not place Android context classes in static fields; this is a memory leak (and also breaks Instant Run) So 2 questions: #1 How do you call a startService from a static method without a static variable for context? #2 How do you send a localBroadcast from a static method (same)? Examples: public static void log(int iLogLevel, String sRequest, String sData) { if(iLogLevel > 0) { Intent intent = new Intent(mContext, LogService.class); intent.putExtra("UPDATE_MAIN_ACTIVITY_VIEW", "UPDATE_MAIN_ACTIVITY_VIEW"); mContext

Override Activity from Android Library project

匿名 (未验证) 提交于 2019-12-03 07:36:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an Android project. Now I need to create a second edition of that project. What will differ: New edition of the Project should have different content in one of the Activities. I was thinking about creating a library project and two new projects( project1 and project2 ) which will use library project, but I don't really understand how to setup this. Should I just convert the original project into library, then create two new projects and then what ? How to make project1 use activity1 and project2 use activity2 in the same place? EDIT

浅析Android 消息机制

旧时模样 提交于 2019-12-03 06:38:16
浅析Android 消息机制 转载: https://www.jianshu.com/p/b6f4e84d53de 消息机制存在的意义 为什么不能在非UI线程中操作UI控件? 因为Android的UI控件不是线程安全的,如果在多线程中并发访问可能会导致UI控件处于不可预期的状态, 为什么不对UI控件加上锁机制? 首先加上锁会让UI访问的逻辑变得复杂;其次锁机制会降低UI访问的效率,因为锁机制会阻塞某些线程的执行 Android是在哪儿校验UI操作是否是在UI线程? //ViewRootImpl.java public ViewRootImpl(Context context, Display display) { ... ... mThread = Thread.currentThread(); ... ... } //该方法会多个方法的开头被调用,例如requestLayout()、invalidateChildInParent()等等... ... void checkThread() { if (mThread != Thread.currentThread()) { throw new CalledFromWrongThreadException("Only the original thread that created a view hierarchy can

Android横竖屏切换解决方案

不想你离开。 提交于 2019-12-03 05:06:06
首先在Mainifest.xml的Activity元素中加入 android:configChanges="orientation|keyboardHidden" 属性 < activity android : name = ".FileBrowser" android : label = "@string/app_name" android : configChanges = "orientation|keyboardHidden" > < intent - filter > < action android : name = "android.intent.action.MAIN" /> < category android : name = "android.intent.category.LAUNCHER" /> </ intent -filter > </ activity > 加入这条属性的含义是,应用程序将会处理屏幕方向和键盘状态(推出或合上)信息的改动。但对于其他的设备配置信息的改动则会由Android系统来处理(销毁当前Activity,然后重启一个新的Activity实例)。 那么,现在还需要在java代码的activity子类中加入配置信息改动的处理代码。这个也很简单 /** * onConfigurationChanged * the package

android多activity退出整个程序的一个实现

折月煮酒 提交于 2019-12-03 05:05:21
多activity中退出整个程序,例如从A->B->C->D,这时我需要从D直接退出程序。 网上资料: { finish()和system(0)都只能退出单个activity。杀进程等的等方式都不行~~~ 解决问题: 我们知道Android的窗口类提供了历史栈,我们可以通过stack的原理来巧妙的实现,这里我们在D窗口打开A窗口时在Intent中直接加入标志Intent.FLAG_ACTIVITY_CLEAR_TOP,再次开启A时将会清除该进程空间的所有Activity。 在D中使用下面的代码: Intent intent = new Intent(); intent.setClass(D.this, A.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); //注意本行的FLAG设置 startActivity(intent); finish();关掉自己 在A中加入代码: Override protected void onNewIntent(Intent intent) { // TODO Auto-generated method stub super.onNewIntent(intent); //退出 if ((Intent.FLAG_ACTIVITY_CLEAR_TOP & intent.getFlags())

Android中Intent组件详解

倾然丶 夕夏残阳落幕 提交于 2019-12-03 04:16:00
Intent是不同组件之间相互通讯的纽带,封装了不同组件之间通讯的条件。 Intent 本身是定义为一个类别(Class),一个Intent对象表达一个目的(Goal)或期望(Expectation),叙述其所期望的服务或动作、与动 作有关的数据等。Android则根据此Intent对象之叙述,负责配对,找出相配的组件,然后将 Intent对象传递给所找到的组件,Android的媒婆任务就完成了。 在Google Doc中是这样描述Intent的 (摘自Android中文翻译组) 当接收到ContentResolver发出的请求后,内容提供者被激活。而其它三种组件──activity、服务和广播接收器被一种叫做intent的异步消息所激活。 intent 是一个保存着消息内容的Intent对 象。对于activity和服务来说,它指明了请求的操作名称以及作为操作对象的数据的URI和其它一些信息。比如说,它可以承载对一个activity 的请求,让它为用户显示一张图片,或者让用户编辑一些文本。而对于广播接收器而言,Intent对象指明了声明的行为。比如,它可以对所有感兴趣的对象声 明照相按钮被按下。 对于每种组件来说,激活的方法是不同的: 1.通过传递一个 Intent对象至 Context.startActivity()或Activity