小编All*_*ker的帖子

源类型1不可用

我有一个适用于iPhone和iPad的应用程序,当我尝试加载UIPickerViewController一个UIPopoverController用于iPad,我得到了异常"源类型1不可用".即使使用该设备也会出现问题.

@try {
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])  {
        UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];

        imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        imagePicker.delegate = self;
        imagePicker.allowsEditing = NO;

        self.tempComp = component;
        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
            [self presentModalViewController:imagePicker animated:YES];
        }else {
            // We are using an iPad
            popoverController=[[UIPopoverController alloc] initWithContentViewController:imagePicker];
            popoverController.delegate = self;

            [popoverController presentPopoverFromRect:component.bounds inView:component permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
        }
    }else{
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Camera Non Disponibile" message:@"La camera non è disponibile" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil];
        [alert show];
    } …
Run Code Online (Sandbox Code Playgroud)

uipickerview uipickerviewcontroller ipad uipopovercontroller ios

37
推荐指数
2
解决办法
2万
查看次数

Android移动使用历史NetworkStatsManager

我正在为Android 6.0制作应用程序,我想使用新类NetworkStatsManager来获取移动数据.

我在清单中添加了我需要的所有权限,并且需要权限运行时.

当我调用方法时:

bucket = networkStatsManager.querySummaryForDevice(ConnectivityManager.TYPE_WIFI, "", fromDate.getTime(), toDate.getTime());
Run Code Online (Sandbox Code Playgroud)

返回正确的WIFI使用价值.

但是如果我用TYPE_MOBILE替换TYPE_WIFI,结果总是为0.

    NetworkStats.Bucket bucket = null;
    try {
        bucket = networkStatsManager.querySummaryForDevice(ConnectivityManager.TYPE_MOBILE, "", fromDate.getTime(), toDate.getTime());

        if(bucket == null){
            Log.i("Info", "Error");
        }else{
            Log.i("Info", "Total: " + (bucket.getRxBytes() + bucket.getTxBytes()));
        }

    } catch (RemoteException e) {
        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

java android networkstatsmanager android-trafficstats

4
推荐指数
1
解决办法
2931
查看次数