[Android] 外部パッケージのActivityを呼び出す方法

Android で、外部パッケージのActivityを呼び出す方法をメモ。

下記のように Intent クラスの setClassName メソッドで直接、指定すればOKです。

(例)アクティビティ com.example.spam.activity.MainActivity を呼び出す

final Intent intent = new Intent();
intent.setClassName("com.example.spam", "com.example.spam.activity.MainActivity");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
activity.startActivity(intent);
activity.finish();

ちなみに、 setClassName メソッドはいくつか引数の渡し方がありますが、今回は下記のような使い方です。

Intent	 setClassName(String packageName, String className)
Convenience for calling setComponent(ComponentName) with an explicit application package name and class name.

[参考]

Intent | Android Developers

Android Intentで画面遷移する(明示的Intent) | Tech Booster

[Android] アプリの国際化対応(英語化・日本語化)

Android でアプリの国際化対応(英語化・日本語化)の方法をご紹介します。

例えば、アプリ名のベースは英語で、言語設定が日本語のときは日本語表記にしたい場合、下記のような感じに設定します。

res/values/strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">SpamApp</string>
</resources>

res/values-ja/strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">スパムアプリ</string>
</resources>

参考情報

Google Analytics SDK for Android v2 の EasyTracker パラメータ

Google Analytics SDK for Android v2 の EasyTracker パラメータについてメモ。

(原文:英語)
Google Analytics SDK for Android v2 – EasyTracker Parameters – Google Analytics — Google Developers

(日本語訳)
EGG 開発ブログ: Google Analytics SDK for Android v2 を訳してみた⑪「EasyTrackerパラメータ」

[Android] Application#onTerminate() は実機端末では動作しない

Android で、Application#onTerminate() メソッドは実機端末では動作しないみたいです。

public void onTerminate ()

This method is for use in emulated process environments. It will never be called on a production Android device, where processes are removed by simply killing them; no user code (including this callback) is executed when doing so.

[引用元]:Application#onTerminate() | Android Developers

詳しくは下記の記事を参考に。

baroqueworksdevの日記: Application#onTerminate()がコールされない

La chiave a sviluppo del software.: Application#onTerminateは、実機では呼ばれない。

[Linux] ファイルのハッシュ値を取得するコマンド

Linux でファイルのハッシュ値を取得するコマンドをご紹介します。

Linux

続きを読む

[Android] android:debuggable でのデバッグモード切り替えは非推奨

Android で、デバッグモードも切り替えに AndroidManifest.xml に android:debuggable=”true” を記載して、デバッグモードを切り替えるのは非推奨みたいです。

Eclipseから実行した場合は自動で android:debuggable=”true” となるので、デバッグモードをOFFにしないなら特に何も気にする必要はないです。

リリース版の apk は、AndroidManifest.xml に何も記載しなければ android:debuggable=”false” の状態になります。

[参考]

android:debuggableでデバッグログ切り替えはやめた方がいい – ReDo

ネタ帳 A.B.C: デバッグビルドとリリースビルドで処理を変える方法

[Android] Waiting for Debugger – Application XXX is waiting for the debugger to Attach エラー

Android アプリをデバッグモードで起動したら、下記のエラーメッセージが表示されて全く起動しませんでした。

■ エラーメッセージ

Waiting for Debugger - Application XXX is waiting for the debugger to Attach

■ 解決方法

Eclipse を再起動する

[参考]

あかばね式 [Android] 「Waiting for Debugger」 メッセージが消えずにハマった

[Android] Nexus7が起動しないときの対処方法

Nexus7が起動しなくて壊れてしまったかと思い、焦りました…

どうやら、完全放電してしまうと電源ボタンを押すだけでは起動しないので、下記の方法で起動させることができます。

電源ボタンを15秒長押しする

or

電源ボタン+音量増ボタン+音量減ボタンの3つを同時に長押しする → 強制終了・起動できる

完全放電してしばらく経つと、上記の手順だけでは全く反応しない場合があるので、そのときはPCにUSB接続して同様の手順を踏むと、起動します。

参考情報

Nexus7が完全放電して起動しない時 : カンマン取締役日記

価格.com – 『強制起動?と初期化について』 Google Nexus 7 Wi-Fiモデル 16GB のクチコミ掲示板

[iOS] xcode cannot run using the selected device – No provisioned iOS devices are available with a compatible iOS version. Connect an iOS device with a recent enough version of iOS to run your application or choose an iOS simulator as the destination.

Xcode でアプリを iPhone へ実機転送しようとしたらエラーが発生して、転送できませんでした。

■ エラー内容

Xcode cannot run using the selected device.

No provisioned iOS devices are available with a compatible iOS version. Connect an iOS device with a recent enough version of iOS to run your application or choose an iOS simulator as the destination.

■ 解決方法

  1. Organize を開く
  2. 左メニューの実機転送したい端末(iPhoneなど)をクリック
  3. 「Use for Development」ボタンをクリック

[参考]

ブランク復帰エンジニアの開発メモ No provisioned iOS devices are available with a compatible iOS version. Connect an iOS device with a recent enough version of iOS to run your application or choose an iOS simulator as the destination.

[Android] Eclipse 経由でエミュレーターのキャプチャーを撮影する方法

Eclipse 経由で Android エミュレーターのキャプチャーを撮影する方法をメモ。

エミュレーター/実機の画面キャプチャ(スクリーンショット)を撮るには – 逆引きAndroid入門