针对android–从其他应用程序打开Twitter应用程序并加载一些页面和安卓打开推特这两个问题,本篇文章进行了详细的解答,同时本文还将给你拓展Android4.x.通过apk部署本机库并从其他应用
针对android – 从其他应用程序打开Twitter应用程序并加载一些页面和安卓打开推特这两个问题,本篇文章进行了详细的解答,同时本文还将给你拓展Android 4.x.通过apk部署本机库并从其他应用程序加载、Android Twitter应用程序开发和TextView和Linkify的使用、android – Facebook和Twitter应用程序的快捷方式发布页面、android – Flutter应用程序页面不断重建等相关知识,希望可以帮助到你。
本文目录一览:- android – 从其他应用程序打开Twitter应用程序并加载一些页面(安卓打开推特)
- Android 4.x.通过apk部署本机库并从其他应用程序加载
- Android Twitter应用程序开发和TextView和Linkify的使用
- android – Facebook和Twitter应用程序的快捷方式发布页面
- android – Flutter应用程序页面不断重建
android – 从其他应用程序打开Twitter应用程序并加载一些页面(安卓打开推特)
例如,我有自己的Android应用程序,我想使用Intent打开Twitter应用程序.
我怎样才能做到这一点?
回答一些例子将非常感激.
解决方法
try{ Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT,"this is a tweet"); intent.setType("text/plain"); final PackageManager pm = getPackageManager(); final List<?> activityList = pm.queryIntentActivities(intent,0); int len = activityList.size(); for (int i = 0; i < len; i++) { final ResolveInfo app = (ResolveInfo) activityList.get(i); if ("com.twitter.android.PostActivity".equals(app.activityInfo.name)) { final ActivityInfo activity=app.activityInfo; final ComponentName name=new ComponentName(activity.applicationInfo.packageName,activity.name); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); intent.setComponent(name); startActivity(intent); break; } } } catch(final ActivityNotFoundException e) { Log.i("twitter","no twitter native",e ); }
Android 4.x.通过apk部署本机库并从其他应用程序加载
然后我需要安装单独的应用程序并使用以下方法加载这些库:
System.load(path_to_lib);
它可以通过哪种方式完成?据我所知,由于安全原因,我不能只使用/data/data/libs_package/lib/native_lib.so路径加载库.还有其他方法吗?
提前致谢.
解决方法
总而言之,谷歌的Android开发者说:
If the two applications have a shared user ID,then you can explicitely call System.loadLibrary() with the full path to the shared library you want to load.
…
But please do not try to do any of this. You are going to cause pain for your users — whether from updates of one or the other app causing incompatibilities and making you break,or the user uninstalling the other app and making you break,etc.
另一位开发人员提出以下解决方案:
So what I do Now (and it works) is have a bunch of packages without a shared user id (they are signed by the same key,but I don’t think that is important here). The core app unzips the .so from the .apk of the other packages (I already have a custom unpacker to workaround a bunch of other Android bugs). I unpack them to a location kNown by the core package and then dlopen() them from there.
Android Twitter应用程序开发和TextView和Linkify的使用
解决方法
android – Facebook和Twitter应用程序的快捷方式发布页面
(作为选择者)
我找到了这个有用的主题:launch facebook app from other app并尝试使用ADB shell命令找到正确的单词(fb:// word),但我无法弄清楚(“发布”,“发布”,“分享”,“分享”不起作用).
然后,当我点击Facebook或Twitter时,我试图捕捉意图选择器上创建的意图(通过日志).我发现 :
“Starting: Intent { act=android.intent.action.SEND typ=text/plain flg=0x3000000 cmp=com.twitter.android/.PostActivity (has extras) } from pid 17575” for Facebook,and
“Starting: Intent { act=android.intent.action.SEND typ=text/plain flg=0x3000000 cmp=com.facebook.katana/.ShareLinkActivity (has extras) } from pid 17575” for Twitter.
我使用以下代码创建了这些意图(在按钮的onClick()方法上):
Intent fbIntent = new Intent(Intent.ACTION_SEND); fbIntent.setType("text/plain"); fbIntent.setFlags(0x3000000); fbIntent.setComponent(new ComponentName("com.facebook.katana",".ShareLinkActivity")); fbIntent.putExtra(Intent.EXTRA_TEXT,getString(R.string.share_text)); startActivity(fbIntent);
我也尝试过这种方式:
Intent twitterIntent = new Intent(Intent.ACTION_VIEW); twitterIntent.setAction("android.intent.action.SEND"); twitterIntent.setFlags(0x3000000); twitterIntent.setType("text/plain"); twitterIntent.setComponent(new ComponentName("com.twitter.android",".PostActivity")); twitterIntent.putExtra(Intent.EXTRA_TEXT,getString(R.string.share_text)); startActivity(twitterIntent);
但即使日志看起来一样,也没有任何事情发生.
任何的想法?
解决方法
intent.setClassName("com.facebook.katana","com.facebook.katana.ShareLinkActivity"); intent.setClassName("com.twitter.android","com.twitter.android.composer.ComposerActivity");
注意:最近的Twitter版本使用’com.twitter.android.composer.ComposerActivity'(而不是’com.twitter.android.PostActivity’)
android – Flutter应用程序页面不断重建
我正在开发一个Flutter应用程序,它会提示表单询问一些个人信息.
问题是每次发生某些事情时都会重建页面,例如屏幕方向改变或文本字段获得焦点时(键盘会立即显示并消失,从而阻止用户输入任何内容).
显然有些事情正在触发不必要的重建,但我无法找到什么和哪里.
当我将此页面作为主页插入时,一切正常.
当我在启动画面上显示动画后将页面插入其预期位置时会出现问题,所以我想这与我的问题有关.
主要课程:
import 'package:Flutter/material.dart';
import './view/SplashScreen.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new SplashScreen(),
);
}
}
启动画面:
import 'package:Flutter/material.dart';
import 'dart:async';
import './UserLoader.dart';
class SplashScreen extends StatefulWidget {
@override
_SplashScreenState createState() => new _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen>
with SingleTickerProviderStateMixin {
AnimationController _iconAnimationController;
CurvedAnimation _iconAnimation;
@override
void initState() {
super.initState();
_iconAnimationController = new AnimationController(
vsync: this, duration: new Duration(milliseconds: 2000));
_iconAnimation = new CurvedAnimation(
parent: _iconAnimationController, curve: Curves.easeIn);
_iconAnimation.addListener(() => this.setState(() {}));
_iconAnimationController.forward();
startTimeout();
}
@override
Widget build(BuildContext context) {
return new Material(
color: Colors.white,
child: new InkWell(
child: new Center(
child: new Container(
width: 275.0,
height: 275.0,
decoration: new Boxdecoration(
image: new decorationImage(
colorFilter: new ColorFilter.mode(
Colors.white.withOpacity(_iconAnimation.value),
BlendMode.dstATop),
image: new Assetimage("images/logo.png")),
),
),
),
),
);
}
void handleTimeout() {
Navigator.of(context).pushReplacement(new MaterialPageRoute(
builder: (BuildContext context) => new UserLoader()));
}
startTimeout() async {
var duration = const Duration(seconds: 3);
return new Timer(duration, handleTimeout);
}
}
页面错误:
import 'package:Flutter/material.dart';
class UserLoader extends StatefulWidget {
@override
_UserLoaderState createState() => new _UserLoaderState();
}
class _UserLoaderState extends State<UserLoader> {
@override
Widget build(BuildContext context) {
final _formKey = new GlobalKey<FormState>();
final _emailController = new TextEditingController();
return new Scaffold(
appBar: new AppBar(
title: new Text("informations"),
actions: <Widget>[
new IconButton(
icon: const Icon(Icons.save),
onpressed: () {
// unrelated stuff happens here
})
],
),
body: new Center(
child: new SingleChildScrollView(
child: new Form(
key: _formKey,
child: new Column(children: <Widget>[
new ListTile(
leading: const Icon(Icons.email),
title: new TextFormField(
decoration: new Inputdecoration(
hintText: "Email",
),
keyboardType: TextInputType.emailAddress,
controller: _emailController,
validator: _validateEmail,
),
),
]))),
));
}}
任何人都可以帮我找出为什么页面不断重建自己?
解决方法:
我通过简单地更改类来解决问题:
import 'package:Flutter/material.dart';
class UserLoader extends StatefulWidget {
@override
_UserLoaderState createState() => new _UserLoaderState();
}
class _UserLoaderState extends State<UserLoader> {
Widget _form; // Save the form
@override
Widget build(BuildContext context) {
if (_form == null) { // Create the form if it does not exist
_form = _createForm(context); // Build the form
}
return _form; // Show the form in the application
}
Widget _createForm(BuildContext context) {
// This is the exact content of the build method in the question
final _formKey = new GlobalKey<FormState>();
final _emailController = new TextEditingController();
return new Scaffold(
appBar: new AppBar(
title: new Text("informations"),
actions: <Widget>[
new IconButton(
icon: const Icon(Icons.save),
onpressed: () {
// unrelated stuff happens here
})
],
),
body: new Center(
child: new SingleChildScrollView(
child: new Form(
key: _formKey,
child: new Column(children: <Widget>[
new ListTile(
leading: const Icon(Icons.email),
title: new TextFormField(
decoration: new Inputdecoration(
hintText: "Email",
),
keyboardType: TextInputType.emailAddress,
controller: _emailController,
validator: _validateEmail,
),
),
]))),
));
}
}
}
希望有一天这可能会帮助别人.
今天的关于android – 从其他应用程序打开Twitter应用程序并加载一些页面和安卓打开推特的分享已经结束,谢谢您的关注,如果想了解更多关于Android 4.x.通过apk部署本机库并从其他应用程序加载、Android Twitter应用程序开发和TextView和Linkify的使用、android – Facebook和Twitter应用程序的快捷方式发布页面、android – Flutter应用程序页面不断重建的相关知识,请在本站进行查询。
本文标签: