Questions tagged «android»

Android是Google的移动操作系统,用于对数字设备(智能手机,平板电脑,汽车,电视,Wear,Glass和IoT)进行编程或开发。对于与Android相关的主题,请使用特定于Android的标签,例如android-intent,android-activity,android-adapter等。对于与开发或编程无关但与Android框架相关的问题,请使用以下链接:https:// android.stackexchange.com。



7
通过Android中的服务获取GPS位置
我需要使用后台服务监视用户的位置,然后加载它们并向用户显示路径。 使用活动,获取GPS位置非常容易,但是当我必须通过服务来获取GPS位置时,我遇到了一个问题,因为它似乎仅适用于弯针线程(或类似的线程)。 当我在互联网上寻找解决方案时,我发现很多人遇到了同样的问题,但是我找不到可行的解决方案。有人说您需要使用prepare-> loop-> quit,而有人说您必须使用handlerThread,但是,我仍然无法找到如何以正确的方式来做这些事情。

6
没有Mac的Xamarin Visual Studio IOS开发?
我是.NET开发人员,想用C#编写IOS和Android应用程序。我已经阅读了有关Visual Studio的Xamarin的内容,即使不是有点贵也看起来很有趣! 您需要Mac来调试代码吗?您只需要联网的Mac即可将应用程序实际部署到商店? 最好的选择是购买Mac并在VM中运行带VS的Windows,还是我可以使用Windows计算机,在Windows中编写和调试代码,然后仅连接到联网的Mac进行最终部署?
70 c#  android  ios  macos  xamarin 

8
如何在适配器中启动Activity?
我有一个带有自定义适配器的ListActivity,并且在每个视图内部,它可能都有一些按钮需要在其中实现OnClickListener。我需要OnClickListener在适配器中实现。但是,我不知道如何像startActivity()或那样调用函数setResult()。由于适配器不会扩展到活动。 那么解决这个问题的最佳方法是什么? 谢谢。

1
在Android的CoordinatorLayout中将另一个视图下方的位置视图
我想用android.support.design.widget.CoordinatorLayout,android.support.design.widget.AppBarLayout,android.support.design.widget.CollapsingToolbarLayout在我的XML文件。将视图放置在另一个视图下方的可能性是什么? 例如:位置ScrollView下方ImageView在CoordinatorLayout。 我的xml代码: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/background_color" tools:context="com.tellfa.smsbox.activities.postShow_Page"> <android.support.design.widget.CoordinatorLayout android:id="@+id/post_show_coordinator" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:id="@+id/app_bar_layout" android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/post_show_collapsing_toolbar_layout" android:layout_width="match_parent" android:layout_height="wrap_content" app:contentScrim="?attr/colorPrimary" app:layout_scrollFlags="scroll|enterAlways" > <ImageView android:id="@+id/post_picture_image" android:layout_width="fill_parent" android:layout_height="200dp" android:scaleType="centerCrop" android:src="@drawable/cover_menu_bg2" android:visibility="visible" app:layout_collapseMode="parallax" /> <android.support.v7.widget.Toolbar android:id="@+id/post_show_app_bar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:layout_collapseMode="pin"> <ImageView android:id="@+id/post_show_fav_image" android:layout_width="25dp" android:layout_height="25dp" android:layout_gravity="right" android:layout_marginRight="10dp" android:alpha="0.7" android:src="@drawable/favorite_post_un" /> …

25
无法解析符号AppCompatActivity-无法识别支持v7库?
我试图弄清楚为什么我的Android Studio无法正确识别AppCompat v7库。下面的import语句显示为灰色,并说没有support.v7.app的软件包。以下是我的活动文件: import android.support.v7.app.AppCompatActivity; public class XApplicationActivity extends AppCompatActivity 我的build.grade: compile "com.android.support:appcompat-v7:22.0.0" compile "com.android.support:support-annotations:$ANDROID_SUPPORT_VERSION" compile "com.android.support:support-v4:$ANDROID_SUPPORT_VERSION" 我的项目设置: minSdkVersion = 14 targetSdkVersion = 21 compileSdkVersion = 21 buildToolsVersion = "22.0.1" 因此,我对于为什么仍然给我带来问题感到非常困惑。我已经尝试过的事情: 清洁/重建项目 使缓存无效并重新启动 检查十亿次以确保我已安装支持库(我确实确实安装了最新的支持存储库和库) 有人知道任何修复程序吗?这花费了我很多时间,而且确实令人沮丧。

17
打开失败:EACCES(权限被拒绝)
我在某些设备上的存储访问遇到了一个非常奇怪的问题。该应用程序可以在我的测试设备(Nexus 4和7,三星GS5)上运行。我所有运行Android 4.4.2的设备。但是我收到了许多用户的电子邮件,称该应用程序无法写入存储设备(内部存储设备或SD卡均无法写入)。从收到用户反馈的日志文件中,我可以看到问题是以下代码: try { if (fStream == null) { fStream = new FileOutputStream(filename, true); } fStream.write(data, 0, bytes); return; } catch (IOException ex) { ex.printStackTrace(); } 它在fStream = new FileOutputStream(filename,true)行处引发异常。创建FileOutputStream时。 堆栈日志为: W/System.err( 8147): Caused by: java.io.FileNotFoundException: /storage/emulated/0/my_folder/test_file_name.png: open failed: EACCES (Permission denied) w/System.err( 8147): at libcore.io.IoBridge.open(IoBridge.java:409) W/System.err( 8147): at …



10
自定义搜寻栏(缩略图大小,颜色和背景)
我想在我的Android项目中使用这个seekbar: 这是我的seekbar: <SeekBar android:id="@+id/seekBar_luminosite" android:layout_width="@dimen/seekbar_width" android:layout_height="@dimen/seekbar_height" android:minHeight="15dp" android:minWidth="15dp" android:maxHeight="15dp" android:maxWidth="15dp" android:progress="@integer/luminosite_defaut" android:progressDrawable="@drawable/custom_seekbar" android:thumb="@drawable/custom_thumb" /> 这是我的custom_thumb.xml: <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" > <gradient android:angle="270" android:endColor="@color/colorDekraOrange" android:startColor="@color/colorDekraOrange" /> <size android:height="35dp" android:width="35dp" /> </shape> 这是我的custom_seekbar.xml: <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@android:id/background" android:drawable="@drawable/seekbar"/> <item android:id="@android:id/progress"> <clip android:drawable="@color/colorDekraYellow" /> </item> </layer-list> 这是我的seekbar.png(背景): 结果是: 酒吧没有阴影,没有圆形的边界... 我真的不知道该怎么办。

3
用户10102和当前进程都不具有android.permission.READ_PHONE_STATE
我正在尝试调用android.telecom.TelecomManager类的getCallCapablePhoneAccounts()方法。尽管我已经添加了必需的用户权限,但是却遇到了Security exception。 这是我遇到异常的代码行 List<PhoneAccountHandle> list = getTelecomManager().getCallCapablePhoneAccounts(); 清单中添加了用户权限 <uses-permission android:name="android.permission.READ_PHONE_STATE" /> 异常stacktrace引起原因:java.lang.SecurityException:getDefaultOutgoingPhoneAccount:用户10102和当前进程都没有android.permission.READ_PHONE_STATE。在android.os.Parcel.readException(Parcel.java:1599)在android.os.Parcel.readException(Parcel.java:1552)在com.android.internal.telecom.ITelecomService $ Stub $ Proxy.getDefaultOutgoingPhoneAccount(ITelecomService.java :615),位于android.telecom.TelecomManager.getDefaultOutgoingPhoneAccount(TelecomManager.java:439)

3
Intent.ACTION_GET_CONTENT和Intent.ACTION_PICK之间的区别
我正在尝试让用户选择要在其设备上用作我正在构建的此壁纸应用程序中的壁纸的任何图像。由于某种原因,当我写: Intent myIntent = new Intent(Intent.ACTION_PICK); myIntent.setType("image/*"); startActivityForResult(myIntent, 100); 我直接进入画廊,但是当我写的时候: Intent myIntent = new Intent(Intent.ACTION_GET_CONTENT, null); myIntent.setType("image/*"); startActivityForResult(myIntent, 100); 我可以从Gallery或Google Drive中选择。让用户每次选择哪个应用来检索图片的最佳方法是什么?还是为什么这两个不同的Intent常数会有所不同?

8
检查是否有正确的Google Play服务可用:“很遗憾,应用程序已停止运行”
每次我在手机上运行应用程序时都会崩溃。有什么不对?它说不幸的是“ appname”已经停止工作。我还尝试了其他方法来检查googleplay服务,但它总是崩溃。我更新了Google Play服务,并且可以正常运行的Google Map v2正常运行。此代码有解决方案吗?它在运行android 4.1.2的手机和AVD上崩溃。 package com.example.checkgoogleplayproject; import android.app.Activity; import android.app.Dialog; import android.os.Bundle; import android.view.Menu; import android.widget.TextView; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.GooglePlayServicesUtil; public class MainActivity extends Activity { @Override protected void onResume() { super.onResume(); // Getting reference to TextView to show the status TextView tvStatus = (TextView)findViewById(R.id.tv_status); // Getting status …
70 android 

12
如何在Android中禁用卡片视图周围的阴影
您好,我正在开发演示应用程序,其中正在使用支持库的卡片视图。默认情况下,它会在其周围添加阴影。我想删除此阴影,看起来应该很简单。 我尝试了这个不适合我的方法。 CardView cardView = (CardView) v.findViewById(R.id.cardView); cardView.setElevation(0); 完成这些后,我崩溃了 11-06 15:12:17.018: E/AndroidRuntime(24315): FATAL EXCEPTION: main 11-06 15:12:17.018: E/AndroidRuntime(24315): Process: com.xyz, PID: 24315 11-06 15:12:17.018: E/AndroidRuntime(24315): java.lang.NoSuchMethodError: android.support.v7.widget.CardView.setElevation 11-06 15:12:17.018: E/AndroidRuntime(24315): at com.xyz.adapters.RecycleViewAdapter.onCreateViewHolder(RecycleViewAdapter.java:85) 11-06 15:12:17.018: E/AndroidRuntime(24315): at com.xyz.adapters.RecycleViewAdapter.onCreateViewHolder(RecycleViewAdapter.java:1) 11-06 15:12:17.018: E/AndroidRuntime(24315): at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:2915) 11-06 15:12:17.018: E/AndroidRuntime(24315): at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:2511) 11-06 15:12:17.018: E/AndroidRuntime(24315): …

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.