タグ付けされた質問 「android」

AndroidはGoogleのモバイルオペレーティングシステムであり、デジタルデバイス(スマートフォン、タブレット、自動車、TV、Wear、Glass、IoT)のプログラミングまたは開発に使用されます。Androidに関連するトピックについては、android-intent、android-activity、android-adapterなどのAndroid固有のタグを使用します。開発やプログラミング以外の質問で、Androidフレームワークに関連する質問については、次のリンクを使用してください:https:// android.stackexchange.com。

5
非アクティビティクラス(LocationManager)でgetSystemServiceを使用するにはどうすればよいですか?
重い作業を行うために、メインのアクティビティのOnCreateメソッドから別のクラスにタスクをオフロードするときに問題があります。 非アクティビティクラスからgetSystemServiceを呼び出そうとすると、例外がスローされます。 どんな助けでも大歓迎です:) lmt.java: package com.atClass.lmt; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import android.location.Location; public class lmt extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); fyl lfyl = new fyl(); Location location = lfyl.getLocation(); String latLongString = lfyl.updateWithNewLocation(location); TextView myLocationText = (TextView)findViewById(R.id.myLocationText); myLocationText.setText("Your current position is:\n" + …
181 android 


24
アクションバーに戻るボタンを表示する
Back button上に表示して、Action bar前のページ/アクティビティまたはメインページ(最初のオープニング)に移動しようとしています。そして、私はそれを行うことができません。 私のコード。 ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(true); コードはにありonCreateます。

10
改良2-動的URL
Retrofit 2では、次のようなサービスメソッドのアノテーションに完全なURLを設定できます。 public interface APIService { @GET("http://api.mysite.com/user/list") Call<Users> getUsers(); } ただし、私のアプリでは、コンパイル時にWebサービスのURLがわからないので、アプリはダウンロードしたファイルでそれらを取得するため、完全な動的URLでRetrofit 2をどのように使用できるのか疑問に思っています。 私はフルパスを設定しようとしました: public interface APIService { @GET("{fullUrl}") Call<Users> getUsers(@Path("fullUrl") fullUrl); } new Retrofit.Builder() .baseUrl("http://api.mysite.com/") .build() .create(APIService.class) .getUsers("http://api.mysite.com/user/list"); // this url should be dynamic .execute(); しかし、ここでは、レトロフィットはパスが実際には完全なURLであり、ダウンロードしようとしていることを認識していません。 http://api.mysite.com/http%3A%2F%2Fapi.mysite.com%2Fuser%2Flist このような動的URLでRetrofitを使用する方法のヒントはありますか? ありがとうございました
181 android  retrofit 



12
プログラムでEditTextにフォーカスを設定(およびキーボードを表示)する方法
私はこのようないくつかのビューを含むレイアウトを持っています: <LinearLayout> <TextView...> <TextView...> <ImageView ...> <EditText...> <Button...> </linearLayout> EditTextプログラムでフォーカスを設定(キーボードを表示)するにはどうすればよいですか? 私はこれを試してみましたActivityが、正常に起動したときにのみ機能しますが、で起動するTabHostと機能しません。 txtSearch.setFocusableInTouchMode(true); txtSearch.setFocusable(true); txtSearch.requestFocus();

11
Android:(サービスから)現在のフォアグラウンドアクティビティを取得するにはどうすればよいですか?
サービスから現在実行中のアクティビティへの参照を取得するネイティブのAndroid方法はありますか? バックグラウンドでサービスを実行していますが、(サービスで)イベントが発生したときに現在のアクティビティを更新したいと思います。それを行う簡単な方法はありますか(私が上で提案したもののように)?

8
ビューの絶対位置を設定する
Androidでビューの絶対位置を設定することは可能ですか?(があることは知っていますが、AbsoluteLayout非推奨です...) たとえば、240x320pxの画面がある場合ImageView、中心が(100,100)の位置になるように20x20pxのを追加するにはどうすればよいですか?


9
エラーメッセージ「java.net.SocketException:socket failed:EACCES(Permission denied)」
エラーメッセージが表示される java.net.SocketException:ソケットの失敗:EACCES(アクセスが拒否されました) 以下のコードを適用しようとすると、これは私が呼び出す関数であり、この例外を私に与えます。 public void run() { // TODO Auto-generated method stub URL myurl = null; try { myurl = new URL("http://10.0.2.2/list.JSON"); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { URLConnection myconn = myurl.openConnection(); InputStream in = new BufferedInputStream(myconn.getInputStream()); InputStreamReader reader = new InputStreamReader(in); …
180 android  json 

9
レトロフィットライブラリでタイムアウトを設定するにはどうすればよいですか?
アプリでRetrofitライブラリを使用していますが、タイムアウトを60秒に設定したいと思います。レトロフィットにはこれを行う方法がありますか? 私はこのようにレトロフィットを設定しました: RestAdapter restAdapter = new RestAdapter.Builder() .setServer(BuildConfig.BASE_URL) .setConverter(new GsonConverter(gson)) .build(); タイムアウトを設定するにはどうすればよいですか?

10
アプリ(22.0.0)とテストアプリ(21.0.3)の解決済みバージョンが異なる
API 22にアップグレードしてlibリビジョン22をサポートした後、次の警告が表示されます。 警告:依存関係「com.android.support:support-annotations」と競合しています。アプリ(22.0.0)とテストアプリ(21.0.3)の解決済みバージョンは異なります。 Gradle自体はより寛容ですが、Android Studioではそれほどではありません。 21.0.3で宣言された依存関係はありません... 21.0.3を使用する依存ライブラリの1つであり、Googleは残りのバッチで更新するのを忘れていますか? build.gradle余分なものを切り取った私の android { compileSdkVersion 22 buildToolsVersion '22' defaultConfig { applicationId "com.REDACTED.android" minSdkVersion 14 targetSdkVersion 22 renderscriptSupportModeEnabled true versionName '1.0.0' versionCode 100 } buildTypes { release { minifyEnabled true zipAlignEnabled true signingConfig signingConfigs.release } debug { minifyEnabled false zipAlignEnabled true signingConfig signingConfigs.debug } } …

22
INSTALL_FAILED_DUPLICATE_PERMISSION…C2D_MESSAGE
私はアプリでGoogle通知を使用しており、今までマニフェストで以下を実行しました: <!-- GCM --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- GCM requires a Google account. --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Keeps the processor from sleeping when a message is received. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- This app has permission to register and receive data message. --> <!-- Creates a custom permission so …

2
2列のグリッドビューと自動サイズ変更画像
2列のグリッドビューを作成しようとしています。この画像のように、1行に2枚の写真を並べて並べます。 しかし、私の写真は同じサイズではないため、それらの間にスペースがあります。これが私が手に入れているものです。 最初の写真を見るとわかるように、連絡先の名前と電話番号を示す凡例が非表示になっています。他の画像は正しく引き伸ばされません。 これがGridView xmlファイルです。ご覧のとおり、columnWidthは200dpに設定されています。自動で行いたいので、画面サイズごとに画像のサイズが自動的に変更されます。 <?xml version="1.0" encoding="utf-8"?> <GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gridViewContacts" android:layout_width="fill_parent" android:layout_height="fill_parent" android:numColumns="2" android:columnWidth="200dp" android:stretchMode="columnWidth" android:gravity="center" /> 各アイテム自体を表すアイテムxmlファイルです。 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <ImageView android:id="@+id/imageViewContactIcon" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="fitXY" /> <LinearLayout android:id="@+id/linearlayoutContactName" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:paddingLeft="5dp" android:paddingTop="5dp" android:paddingBottom="5dp" android:background="#99000000" android:layout_alignBottom="@+id/imageViewContactIcon"> <TextView android:id="@+id/textViewContactName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textStyle="bold" android:textSize="15sp" …

弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.