小编The*_*ash的帖子

android java.io.IOException:服务不可用

描述:我正在使用Google maps API V2.我已Android Reverse Geocoding在触摸位置实施.

问题:它抛出异常

 try {
     addresses = geocoder.getFromLocation(latitude, longitude,1);}
 catch (IOException e)
     {
     e.printStackTrace();
     if(AppConstants.DEBUG)Log.v(AppConstants.DEBUG_TAG," e.printStackTrace(): "+e.getMessage());
     }
Run Code Online (Sandbox Code Playgroud)

我收到latitude并且longitude价值正确,但我无法理解为什么它会抛出exception,我也做了谷歌搜索,但它无能为力.

任何人都可以详细解释一下吗?

android google-maps-android-api-2

35
推荐指数
3
解决办法
3万
查看次数

android将圆分成N个相等的部分并知道每个分界点的坐标

我要求根据数字(2,3 ... n)将一个圆分成N个相等的部分.但我想要分割点的坐标.

我有一个圆圈,centre(x,y)并且radius(150)已知.

题:

是否有任何公式给出了分割点的坐标,如图所示.谁能告诉我这个公式.我想用Java实现它.

用于参考的圆形图像:

图片

math geometry android

16
推荐指数
2
解决办法
9877
查看次数

VideoView闪烁问题

我正面临着奇怪的闪烁问题VideoView.当活动开始时,它会导致轻微的分数闪烁一秒钟.然后,视频开始.它在视频的顶部和底部显示2条黑线.请参阅下面的快照.

检查快照

我在2台设备上测试了我的应用程序

1)三星n-8000(平板电脑)

2)联想a-800

video.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:background="#ffffff"
 android:gravity="center">

 <VideoView 
    android:id="@+id/vvSplash"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:background="#00ffffff">
</VideoView>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

活动代码:

private VideoView vd;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.video);
    vd = (VideoView) findViewById(R.id.vvSplash);
    playVideo();
}

private void playVideo() {
    Uri uri = Uri.parse("android.resource://" + getPackageName() +"/"+ R.raw.intro);
    vd.setVideoURI(uri);
    vd.setMediaController(null);
    vd.start();     
}
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激.谢谢.

android android-videoview

8
推荐指数
1
解决办法
6025
查看次数

如何在Android中以任何扩展名打开文件?

你好读者和助手。

(我是新手)

说明:

我有1个应用程序,用户可以在其中上传任何扩展名的文件(.png.mp3.txt.pdf.bmp.apk等。)

简而言之-> **带有任何exe ..!**的文件

这些文件显示在列表视图中。

当用户在列表视图意图中的项目上“点击”或“单击”时,将被称为(android.content.Intent.ACTION_VIEW),并且应打开设备中安装的相应应用程序。

例如

如果用户单击nature.png,则将调用意图并建议诸如Gallery,PS Touch..etc之类的应用程序(如屏幕截图1所示

如果用户单击book.pdf,则将调用意图并建议诸如MuPdf,Polaris Office,apv..etc之类的应用程序(如屏幕截图2所示

对于.txt,.pdf,.png,.jpg-我已经通过设置mime类型解决了这个问题intent.setDataAndType(Uri.fromFile(file), mime);

并且为URL

Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse(https://www.google.co.in/));
Run Code Online (Sandbox Code Playgroud)

它工作正常,但对于文件扩展名的其余部分,我仍然感到困惑-该怎么办?怎么办?

我已经四处搜寻,但是无法令人满意地回答..!

我的问题:

  1. 我如何为任何文件扩展名编写代码,以便它可以调用设备中安装的各个应用程序?
  2. 如何在XML中定义自定义文件扩展名?

android

7
推荐指数
1
解决办法
8504
查看次数

转换为Dalvik格式失败:无法执行dex:超出GC开销限制

我在最近3个小时内遇到了这个错误.当我从SVN检查出最新的代码之后,它突然停止工作了.

注意:

我的新项目大小约为135 MB,我使用的是eclipse kepler.

myApp/res/libs中还有3个jars,名为sqlite.jar,ksoap2.jar,rt.jar

所以我用Google搜索并找到了这个答案.还有Blog 1Blog 2我编辑了eclipse.ini

从:

-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20140116-2212
-product
org.eclipse.epp.package.standard.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Xms40m
-Xmx512m
Run Code Online (Sandbox Code Playgroud)

-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20140116-2212
-product
org.eclipse.epp.package.standard.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
1024M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
1024m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Xms512m
-Xmx1024m 
Run Code Online (Sandbox Code Playgroud)

但它仍然没有工作,并在日食中得到相同的错误.任何帮助,将不胜感激.

eclipse android dalvik dex

5
推荐指数
1
解决办法
7095
查看次数

如何在Android的警告对话框的顶角放置关闭按钮?

如何在Android的警告对话框的顶角放置关闭按钮?

在警告对话框中将关闭按钮放在右上角.

我使用下面的代码滚动和对话框

<ScrollView 
        android:id="@+id/ScrollView01" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        xmlns:android="http://schemas.android.com/apk/res/android">

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical"
   android:scrollbars="vertical" 
   android:scrollbarAlwaysDrawVerticalTrack="true" >
Run Code Online (Sandbox Code Playgroud)

<ImageVieandroid:id="@+id/image"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_alignParentRight="true"
 android:layout_alignParentTop="true"
 android:layout_marginLeft="200dp"
 android:src="@drawable/ic_launcher" />

</RelativeLayout>

</ScrollView>
Run Code Online (Sandbox Code Playgroud)

在java编码我已经使用下面的编码我想把图像关闭对话框请帮忙

public void onClick(View v) 
{
// TODO Auto-generated method stub
   switch (v.getId())
   {
    case R.id.How_to_use:

 final Dialog dialog = new Dialog(this);
 dialog.setContentView(R.layout.description);
 dialog.setTitle("How to use");
 TextView text = (TextView) dialog.findViewById(R.id.description);
 text.setText(R.string.Descr_How_to_use);
 ImageView image = (ImageView) dialog.findViewById(R.id.image);
 image.setImageResource(R.drawable.ic_launcher);
 image.setOnClickListener(new OnClickListener() 
 {
  // @Override
  public void onClick(View v) {
  dialog.dismiss();
  }
  });
 dialog.show();
 break;
 default: …
Run Code Online (Sandbox Code Playgroud)

android android-layout

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

从文件中检索JSONObject

我想存储JSONObject在文件中。为此,我将对象转换为字符串,然后将其存储在文件中。我使用的代码是:

String card_string =  card_object.toString();
//card_object is the JSONObject that I want to store.

f = new File("/sdcard/myfolder/card3.Xcard");
//file 'f' is the file to which I want to store it.

FileWriter  fw = new FileWriter(f);
fw.write(card_string);
fw.close();
Run Code Online (Sandbox Code Playgroud)

该代码按我的意愿工作。现在,我从文件中检索该对象。我该怎么办?我对使用什么读取文件感到困惑?一个InputStreamFileReaderBufferedReader或什么。我是JAVA / android开发的新手。

请帮忙。欢迎用简单的语言详细说明在不同情况下(例如这样)要使用哪些I / O功能。我看过文档,但是欢迎您提出建议。

file-io android json

2
推荐指数
1
解决办法
6570
查看次数

CloudKit - 如何共享多条记录并检索共享记录?

我在WWDC 2016上观看了CloudKit的新功能,了解如何使用CKShare与其他用户共享记录

单记录共享:

我能够共享和检索单个记录

即如果xyz@gmail.com创建并共享一条记录到abc@gmail.com

多条记录共享:

假设有10条记录,xyz @ gmail.com想要分享到 abc@gmail.com.我面临的问题,当用户xyz@gmail.com股份多个记录用户abc@gmail.com

到目前为止我尝试了什么:

首先,我创建了3个音符记录:

注1

注2(将父设为Note1)

注3(将父设为Note1)

我用下面的代码分享了Note1(父记录):

代码 - 共享记录

let controller = UICloudSharingController { controller,
        preparationCompletionHandler in

        let share = CKShare(rootRecord: self.parentRecord!)
        share[CKShareTitleKey] = "note" as CKRecordValue
        share.publicPermission = .readOnly

        let operation = CKModifyRecordsOperation(
              recordsToSave: [self.parentRecord!, share],
              recordIDsToDelete: nil)

        operation.perRecordCompletionBlock = { (record, error) in
            if let error = error {
                print("CloudKit error: \(error.localizedDescription)")
            } …
Run Code Online (Sandbox Code Playgroud)

ios icloud swift cloudkit

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