mIntent = new Intent(Intent.ACTION_SEND);
mIntent.putExtra(Intent.EXTRA_SUBJECT, getString(""));
mIntent.setType("text/html");
Uri myUri = Uri.parse("http://www.Google.com/");
mIntent.putExtra(android.content.Intent.EXTRA_TEXT,Html.fromHtml("<a href=\""+myUri+"\">Link</a>"));
startActivity(android.content.Intent.createChooser(mIntent, "Email:"));
Run Code Online (Sandbox Code Playgroud)
我尝试了上面的代码,但在接收方,我无法获得链接.它转换成普通文本..
我正在Java/Android中实现加密代码以匹配iOS加密.在iOS中,使用以下填充方案使用RSA加密:PKCS1-OAEP
但是当我尝试用PKCS1-OAEP创建Cipher时.
Cipher c = Cipher.getInstance("RSA/None/PKCS1-OAEP", "BC");
Run Code Online (Sandbox Code Playgroud)
下面是堆栈跟踪
javax.crypto.NoSuchPaddingException: PKCS1-OAEP unavailable with RSA.
at com.android.org.bouncycastle.jcajce.provider.asymmetric.rsa.CipherSpi.engineSetPadding(CipherSpi.java:240)
at javax.crypto.Cipher.getCipher(Cipher.java:324)
at javax.crypto.Cipher.getInstance(Cipher.java:237)
Run Code Online (Sandbox Code Playgroud)
也许这RSA/None/PKCS1-OAEP是不正确的?但无法找到任何明确的答案,要么说PKCS1-OAEP不受支持,要么是正确的定义方式.
我正在使用spongycastle库,所以有完整的bouncycastle实现.
我有一个活动来通过我的应用程序捕获ACTION_CALL意图intent-filter和路由,这在Nexus one,Moto Blur和Samsung设备上运行良好.但不是HTC意义上的.:(
将Intent.ACTION_CALL_BUTTON在何时被称为HTC Sense的按钮被按下,但是当你拨打ACTION_CALL时,未收到日志输出显示的android.intent.action.CALL发送.
06-17 12:22:45.173: INFO/ActivityManager(83): Starting activity: Intent {
act=android.intent.action.CALL dat=tel:00390642200001 flg=0x10000000
cmp=com.android.phone/.InCallScreen (has extras) }
Run Code Online (Sandbox Code Playgroud)
我猜这是因为HTC已经把他们自己的感觉拨号器和它做了一些有趣的事情(可能有意图过滤器优先级?).
Updated1:尝试将优先级设置为max int值,没有变化.
<intent-filter android:priority="2147483647">
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.CALL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud) 有没有办法获取所有联系人的所有电话号码,而无需为每个联系人单独查询?(使用Android 2.0+).如果你有超过100个联系人(在低端手机上无法使用),它真的很慢,我想知道我是否可以做更有效的查询.
目前我正在获取一个包含所有有效ContactsContract.Contacts.IN_VISIBLE_GROUP联系人的游标,然后为每个联系人单独查询以获取所有数字.
获取联系人的代码片段仅提供名称和查找键:
Uri uri = ContactsContract.Contacts.CONTENT_URI;
String[] projection = new String[] {
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts.LOOKUP_KEY};
Run Code Online (Sandbox Code Playgroud)
然后使用查找键进行每次联系.
Uri lookupUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey);
Uri res = ContactsContract.Contacts.lookupContact(contentResolver, lookupUri);
String[] projection = new String[]{ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.Contacts.HAS_PHONE_NUMBER};
Run Code Online (Sandbox Code Playgroud)
...
Cursor phones = contentResolver.query( ContactsContract.CommonDataKinds.Phone.CONTENT_URI, phoneProjection, selection, selectionArgs, sortOrder);
Run Code Online (Sandbox Code Playgroud) 我已设法使用以下内容获取加载和播放的vimeo视频.但是,vimeo oembed doc中指示的autoplay = 1 不会在加载时自动播放.任何人都找到了自动播放的方法(也需要在视频播出时捕捉事件)
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setAppCacheEnabled(true);
mWebView.getSettings().setDomStorageEnabled(true);
// how plugin is enabled change in API 8
if (Build.VERSION.SDK_INT < 8) {
mWebView.getSettings().setPluginsEnabled(true);
} else {
mWebView.getSettings().setPluginState(PluginState.ON);
}
mWebView.loadUrl("http://player.vimeo.com/video/24577973?player_id=player&autoplay=1&title=0&byline=0&portrait=0&api=1&maxheight=480&maxwidth=800");
Run Code Online (Sandbox Code Playgroud) 我发现了这个好奇的OutOfMemoryError,我想知道是否有其他人遇到过它.我稍微违反了SharedPreferences的规则,并将一些模型对象存储为字符串,但这些对象很小.
java.lang.OutOfMemoryError
at com.android.internal.util.FastXmlSerializer.(FastXmlSerializer.java:55)
at com.android.internal.util.XmlUtils.writeMapXml(XmlUtils.java:177)
at android.app.SharedPreferencesImpl.writeToFile(SharedPreferencesImpl.java:596)
at android.app.SharedPreferencesImpl.access$800(SharedPreferencesImpl.java:52)
at android.app.SharedPreferencesImpl$2.run(SharedPreferencesImpl.java:511)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
Run Code Online (Sandbox Code Playgroud) 我必须在动作布局中缺少android:visibility更改。这是我的布局的简化版。
<MotionLayout>
<ImageView android:id="@+id/HeaderBackground" />
Bunch of image views, Text views that are constrainted to the HeaderBackground.
<RecyclerView android:visibility="visible">
<EditText android:visibility="visible">
<CustomViewGroup1 android:visibility="gone">
</MotionLayout>
Run Code Online (Sandbox Code Playgroud)
我有一个MotionScreen,它基于回收者视图设置了一个onswipe过渡,以减小HeaderBackground的高度并隐藏一些图像/文本视图(例如,折叠工具栏)。但是,如果出现一些致命错误,我想在RecyclerView的顶部/前面显示CustomViewGroup1,但是将RecyclerView的可见性切换为“消失”,而将CustomViewGroup1切换为可见,则不会显示CustomViewGroup1。
我可以将CustomViewGroup组从MotionLayout中移出,并添加framelayout作为活动的根,并隐藏整个MotionLayout。但这并不理想,因为我必须复制工具栏和图标。所以我想问题是关于可见性的变化和潜在的z顺序?
我正在使用 androidx.constraintlayout:constraintlayout:2.0.0-beta2
我们有一个在创建应用程序时运行的任务,并且我们尝试将代码从应用程序对象的 onCreate 移动到它们自己的生命周期感知类。我已将ApplicationLifecycleAwareTaskRunner(a ) 添加到inLifecycleObserver的生命周期中,但它从未被调用。和被按预期调用。ProcessLifecycleOwnerApplication.onCreate()onCreate(owner: LifecycleOwner)onStart(..)onStop()
LifecycleObserver这是它无法观察事件的已知限制吗Application.onCreate()?或者我在这里缺少什么?
使用androidx.lifecycle:lifecycle-runtime-ktx:2.4.1
在应用程序对象中添加观察者。
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
// DI and other init
ProcessLifecycleOwner.get().lifecycle.addObserver(ApplicationLifecycleAwareTaskRunner(..))
}
}
Run Code Online (Sandbox Code Playgroud)
任务运行者:
class ApplicationLifecycleAwareTaskRunner(
private val appCoroutineScope: CoroutineScope,
private val myTask: MyTask
) : DefaultLifecycleObserver {
// This is never called :(
override fun onCreate(owner: LifecycleOwner) {
appCoroutineScope.launch {
myTask.invoke()
}
}
...
}
Run Code Online (Sandbox Code Playgroud) 我有一个ListView,其行由我格式化.每行都有ImageView和TextView的混合.我也实现了自己的适配器,并能够通过它绘制每一行.
现在,我想要这样的东西 -
我为此尝试了很多东西,并希望我的代码尽可能高效(就过度杀伤而言).目前我只能捕获特定ImageView上的click事件,但我不知道单击了哪一行.
我在Row XML中提供了一个属性,如下所示 -
<ImageView android:id="@+id/user_image"
android:padding="5dip"
android:layout_height="60dip"
android:layout_width="60dip"
android:clickable="true"
android:onClick="uImgClickHandler"/>
Run Code Online (Sandbox Code Playgroud)
在我的代码中,我有一个像这样的方法:
public void uImgClickHandler(View v){
Log.d("IMG CLICKED", ""+v.getId());
LinearLayout parentRow = (LinearLayout)v.getParent();
}
Run Code Online (Sandbox Code Playgroud)
我可以得到父行(也许),但我不确定如何从这里走得更远.有人可以帮忙吗?
试图拦截传出呼叫,并使解决方案运行良好
但不是三星Galaxy S运行2.1,有人见过这个吗?
<receiver android:name="com.mypackge.OutGoingCallDetection"
android:exported="true">
<intent-filter>
<action
android:name="android.intent.action.NEW_OUTGOING_CALL"
android:priority="0" />
</intent-filter>
</receiver>
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
Run Code Online (Sandbox Code Playgroud)
更新:还添加了PROCESS_OUTGOING_CALLS.
收件人:
public class OutGoingCallDetection extends BroadcastReceiver {
private static final String TAG = "OutGoingCallDetection";
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.d(TAG, "onReceive, Action:" +intent.getAction());
}
}
Run Code Online (Sandbox Code Playgroud) android ×10
bouncycastle ×1
contacts ×1
htcsense ×1
html-email ×1
intentfilter ×1
java ×1
security ×1
vimeo ×1