android APK在一个APK中?(android APK within an APK?)
正如我上面的问题所述,是否有可能在另一个APK中有一个apk文件? 为了进一步解释,这里是我的情况:
我有两个应用程序,第一个通过意图调用另一个。我没有这个问题..但我需要的是只安装一个apk文件而不是两个。 我想到的第一件事是将一个.apk文件放在另一个.apk文件中。我真的不知道这是否可能,这就是为什么我需要这样做。 但如果这是不可能的,我希望有人能告诉我做这种事情的最佳做法是什么。
我可以将它作为一个应用程序,但这将是我的最后一个解决方案。
As stated in my question above, is it possible to have an apk file within another apk? To further explain, here is my situation:
I have two apps and the first one calls the other through an intent.. I don't have problem with this.. But what I need is to install only one apk file instead of two. And the first thing that came into my mind is to put a .apk file inside the other .apk file.. I really don't know if this is possible that's why I need your take on this. But if this is not possible, I hope someone can tell me what would be the best practice to doing this kind of thing.
I can make it as one application, but that would be my last solution.
原文:https://stackoverflow.com/questions/4800672
最满意答案
一个
CLLocation!
变量是可选的,但它只是一个隐式解包的变量。 正如The Swift Programming Language:The Basics所说:[Optionals]表示允许常量或变量具有“无值”。 可以使用if语句检查Optionals,以查看是否存在值,并且可以使用可选绑定有条件地解包,以访问可选的值(如果存在)。
有时从程序的结构中可以清楚地看出,在首次设置该值之后,可选项将始终具有值。 在这些情况下,每次访问时都不需要检查和解包可选的值,因为可以安全地假设它始终具有值。
这些类型的选项被定义为隐式解包的选项。 您可以通过在要使其成为可选类型之后放置感叹号(
String!
)而不是问号(String?
)来编写隐式解包的可选项。因此,
location
是一个可选项,但您不必在每次使用它时都显式解包它,因为它是一个隐式解包的。A
CLLocation!
variable is an optional, but it is just a implicitly unwrapped one. As The Swift Programming Language: The Basics says:[Optionals] indicate that a constant or variable is allowed to have “no value”. Optionals can be checked with an if statement to see if a value exists, and can be conditionally unwrapped with optional binding to access the optional’s value if it does exist.
Sometimes it is clear from a program’s structure that an optional will always have a value, after that value is first set. In these cases, it is useful to remove the need to check and unwrap the optional’s value every time it is accessed, because it can be safely assumed to have a value all of the time.
These kinds of optionals are defined as implicitly unwrapped optionals. You write an implicitly unwrapped optional by placing an exclamation mark (
String!
) rather than a question mark (String?
) after the type that you want to make optional.So,
location
is an optional, but you don't have to explicitly unwrap it every time you use it because it is an implicitly unwrapped for you.
相关问答
更多-
您的placemark变量被声明为显式解包的可选项,但由于您收到此错误消息,很明显有时此变量将为nil。 更改声明使其成为普通的可选,然后使用if let来确保安全解包和处理错误: var placemark : CLPlacemark? @IBAction func addPlace(sender: AnyObject) { if let mark = placemark { let locality = String(self.mark.locality) ...
-
Swift - 自己的当前位置结构/类(CLLocationManager)(Swift - Own struct/class for current location (CLLocationManager))[2022-02-04]
您的代码有两个观察结果: 完成成员变量设置后,您不会在init中调用[super init]。 将init修改为 init(){ placemark = CLPlacemark() mLocationManager = CLLocationManager() mLocationManager.desiredAccuracy = kCLLocationAccuracyBest mLocationManager.requestWhenI ... -
一个CLLocation! 变量是可选的,但它只是一个隐式解包的变量。 正如The Swift Programming Language:The Basics所说: [Optionals]表示允许常量或变量具有“无值”。 可以使用if语句检查Optionals,以查看是否存在值,并且可以使用可选绑定有条件地解包,以访问可选的值(如果存在)。 有时从程序的结构中可以清楚地看出,在首次设置该值之后,可选项将始终具有值。 在这些情况下,每次访问时都不需要检查和解包可选的值,因为可以安全地假设它始终具有值。 这些类 ...
-
GPS是一项不完善的技术。 大气条件,卫星可用性(和位置),天空能见度,附近物体(建筑物)反射的信号都会导致其固有的不准确性。 尽管甚至有一个“精度”值( 通常相当不错) - 即使这不是完全可靠的。 飞机不允许使用GPS进行精确测量 - 即使他们的接收机不够精确,并且需要其他技术(这有其自身的问题)。 尝试运行标准的“地图”应用程序并将其用作比较。 我认为你的代码很好 - 它只是GPS而已。 当然,我这样说是因为我正在开发自己的海上导航应用程序,自己也遇到过所有这些问题。 GPS is an imperfe ...
-
在调用lm.startUpdatingLocation() ,只要位置管理器检测到位置更改就调用didUpdateLocations() ,因此您需要实现CLLocationManager::didUpdateLocations来检索位置: import UIKit import MapKit import CoreLocation class mapClass : UIViewController,MKMapViewDelegate,CLLocationManagerDelegate{ var ...
-
我相信这是一个错误,我已经向Apple提交了一个错误报告。 在开放式雷达上可以找到错误报告的镜像: http://openradar.appspot.com/radar?id=2682402 I believe this to be a bug and I have filed a bug report with Apple. A mirror of the bug report can be found on Open Radar: http://openradar.appspot.com/radar?i ...
-
您不希望假定位置管理器具有有效location 。 你也不想有一个while循环或一个计时器,等待它。 你想要做的是在viewDidLoad启动定位服务,使用requestWhenInUseAuthorization或requestAlwaysAuthorization请求定位服务的权限(确保已经设置了NSLocationWhenInUseUsageDescription或NSLocationAlwaysUsageDescription键的合适的plist字符串),然后等待CLLocationManager ...
-
这是一个众所周知的问题。 在Xcode to Edit Scheme中 - >禁用Metal Api将解决问题。 It is a well known issue. In Xcode to Edit Scheme -> Disable Metal Api will fix the issue.
-
当您监控该区域时,所需的准确性没有意义。 这是因为它不适用于基于位置的精确结果。 它们为您提供了用户的暂定位置。 使用标准服务并调用函数[locationManager startUpdatingLocation];时,精度适用[locationManager startUpdatingLocation]; 。 在区域监控和重要位置变化的情况下,忽略准确性。 When you are monitoring the region, desired accuracy has no significance. T ...
-
使用'!'时需要小心 打开可选项或转换值。 这说“我知道这不是nil /这个类的一个实例,如果不是,这很糟糕并抛出异常” 。 如果它有可能是nil /不是所需类的实例,那么你应该使用'?' 适当地对结果采取行动。 if let userLoc = NSUserDefaults.standardUserDefaults().objectForKey("Location") as? [String : NSNumber] { //Grab location from that Dictionary ( ...