我知道Gradle很强大,我想管理用于开发/生产Google Maps的API密钥
目前我总是需要手动注释一行并取消注释另一行以使其工作.有没有办法在Gradle中自动执行一些自定义发布配置?
<!-- MapView v2 API -->
<uses-library android:name="com.google.android.maps" />
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="[MY_DEV_KEY]" />
<!-- PROD
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="[MY_PROD_KEY]" />
-->
Run Code Online (Sandbox Code Playgroud) 有没有办法直接在Gradle中包含Apache库以使其与Android 6.0一起使用?
我试图包括这样的库:
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
Run Code Online (Sandbox Code Playgroud)
并且Android Studio无法找到以下导入:
import org.apache.http.auth.AuthenticationException;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.MalformedChallengeException;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.impl.auth.DigestScheme;
Run Code Online (Sandbox Code Playgroud) android apache-httpclient-4.x android-gradle-plugin android-6.0-marshmallow
我有一个ListView,我希望每行填充可用屏幕的三分之一.我可以看到状态栏,然后是一个带有slidingTabs的actionBar.我正在做这样的当前计算:
height = context.getResources().getDisplayMetrics().heightPixels;
if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))
{
actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,context.getResources().getDisplayMetrics());
Log.d("actionBarHeigth", actionBarHeight.toString());
}
Run Code Online (Sandbox Code Playgroud)
并设置视图高度如下:
holder.imageView.getLayoutParams().height = (height - actionBarHeight*2) / 3;
Run Code Online (Sandbox Code Playgroud)
但是列表的行有点太大了,我想这是导致它的状态栏.如何将其高度添加到我的计算中?
我的资源文件夹中有不同的strings.xml文件(values,values_fr,values_de ...),我想在运行时加载其他翻译.是否可以将新字符串添加到这些文件中,即使它已经被编译了?或者有解决方法吗?
我尝试在许多Android设备之间创建一个ad-hoc网络,但我找不到文档来做到这一点.
我认为Wifi direct可以满足我的需求,但是可以在一台设备上进行多次连接吗?我看到我们可以做一个像接入点一样的设备并与许多设备通信,但是我们可以从一个客户端设备与两个接入点设备进行通信吗?
我有3个设备:A - > B - > C.
"A"设备需要与"C"设备通信但是他太远了,所以我想在A&B和B&C之间的ad-hoc wifi直接连接之间进行ad-hoc wifi直接连接,所以A可以与C通信.也应该使用3个以上的设备.
谢谢 !
我找不到一种方法来保持我的应用程序样式,并在"当前播放"弹出屏幕中显示文本.它在白色为白色,如下图所示.
似乎textColor用于文本,colorPrimary用于背景.我有两个白色,因为它在应用程序的其他部分使用.有没有办法只给这个对话框一个主题?
<style name="Theme.MyTheme" parent="Theme.AppCompat">
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">@color/white</item>
<!-- colorPrimaryDark is used for the status bar background -->
<item name="colorPrimaryDark">@color/black</item>
<!-- Light action bar starting with Android M -->
<!-- <item name="android:windowLightStatusBar">true</item> -->
<!-- colorAccent is used as the default value for colorControlActivated, which is used to tint widgets -->
<item name="colorAccent">@color/accent</item>
<item name="colorControlNormal">@color/gray</item>
<item name="colorControlHighlight">@color/gray_lighter</item>
<!-- Customize actionbar element in white because we use a Light Theme with a …
Run Code Online (Sandbox Code Playgroud) 我对 Hilt 注射还很陌生。我开始将我的整个项目迁移到 DI。
它几乎在任何地方都适用,但当涉及到后仰演示者时,我遇到了一个问题。我不知道这是否与后倾的东西有关或只是希尔特
class LiveShowCardPresenter constructor(context: Context, listener: ShowCardViewListener, val hasVariableWidth: Boolean = false) : ShowCardPresenter(context, listener) {
override fun onCreateViewHolder(parent: ViewGroup): ViewHolder {
val viewholder = ViewHolder(LiveShowCardView(context, hasVariableWidth))
viewholder.prepareViewHolderForeground(context, settings.isATV)
return viewholder
}
...
}
Run Code Online (Sandbox Code Playgroud)
abstract class ShowCardPresenter constructor(val context: Context, var listener: ShowCardViewListener?) : Presenter() {
@Inject lateinit var detailsRepository: DetailsRepository
@Inject lateinit var settings: BackendSettings
... }
Run Code Online (Sandbox Code Playgroud)
@Singleton
class BackendSettings @Inject constructor(@ApplicationContext val context: Context) {
val isATV = true // TODO
Run Code Online (Sandbox Code Playgroud)
出现以下错误
kotlin.UninitializedPropertyAccessException: lateinit …
Run Code Online (Sandbox Code Playgroud) 我尝试在类中建立多个连接并更新主屏幕中的多个进度条.
但我尝试在android中使用线程时出现以下错误:代码:05-06 13:13:11.092:错误/ ConnectionManager(22854):错误:无法在未调用Looper.prepare的线程内创建处理程序( )
这是我的主要Activity中的一小部分代码
public class Act_Main extends ListActivity
{
private ConnectionManager cm;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Set up the window layout
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
}
public void startConnection()
{
//open DB connection
db = new DBAdapter(getApplicationContext());
db.open();
cm = new ConnectionManager(handler, db);
showDialog(DIALOG_PROGRESS_LOGIN);
}
@Override
public void onStart()
{
super.onStart();
startConnection();
}
protected Dialog onCreateDialog(int id)
{
switch (id)
{
case DIALOG_PROGRESS_LOGIN:
progressDialog = new ProgressDialog(Act_Main.this);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setMessage("Connecting.\nPlease wait...");
progressThreadLogin = new ProgressThreadLogin(); …
Run Code Online (Sandbox Code Playgroud) android ×7
adhoc ×1
ancs ×1
chromecast ×1
connection ×1
dagger-hilt ×1
google-cast ×1
gradle ×1
handler ×1
ios ×1
key ×1
localization ×1
runtime ×1
wifi ×1
xml ×1