标签归档:android

Android Python编程[关闭]

问题:Android Python编程[关闭]

我可以使用Python为Android编程吗?我在搜索时似乎偶然发现了许多链接…但是它们都不是具体的。

有什么建议?我想为Android编写应用程序,但实际上并不想为此而涉足Java。

PS:我的问题是我是否可以编写适用于Android的功能完善的应用程序。

Can I program for Android using Python? I seem to have stumbled upon many links while searching… however neither of them is concrete.

Any suggestions? I want to write apps for Android but really don’t want to get into Java for all this.

PS: My question is whether I can write proper, full fledged apps for Android.


回答 0

结帐Kivy。到目前为止,他们的工作非常出色,我非常喜欢他们的工作。它仍然缺少一些提供程序,但是他们每天都在增加新的内容。您需要做的第一件事是根据文档提供的内容检查需求。他们创建了一个惊人的输入框架,例如多点触摸或笔处理。他们在内部使用OpenGL ES,因此与应用程序进行交互时,复杂的图形和可视化可以非常快速地运行。他们创建apk的过程也非常简单。

Checkout Kivy. They have done a really great job so far, and I am a big fan of their work. It is still lacking some providers, but they keep adding new stuff to it everyday. First thing you need to do is to check your requirement against what they can offer based on their documentation. They have create an amazing framework for input such as multi-touch or pen handling. They use OpenGL ES internally, as a result complex graphics and visualizations can run very fast when interacting with the the application. Their process for creating an apk is also very straight forward.


回答 1

检查新的Android版Python项目。

编辑:这不是Kivy,这是一个单独的项目,旨在成为可用于其他工具箱的工具链。该架构是模块化的,并且您可以包括用于包含新的python扩展(例如brew,macports,cygwin等)的新配方。

编辑:这不是Py4A,而是python-for-android。

Check the new Python for Android project.

Edit: This is not Kivy, this is a seperate project, intended to be a toolchain usable for other toolkit. The architecture is modular, and you can include new recipe for including new python extensions (as brew, macports, cygwin etc.).

Edit: This is not Py4A, but python-for-android.


回答 2


回答 3

不,目前不行。ASE(Android脚本环境)允许您执行简单的脚本应用,但是您只能用Java编写适当的Android应用。

No, not currently. ASE (Android Scripting Environment) allows you to do simple script apps, but you can only write proper Android apps in Java.


回答 4

是的,可以。检查ASE

编辑:好的,经过评论:我没有正确阅读问题。不,您不能编写适用于Android的功能完善的成熟应用程序,但是无论如何都要检查ASE。这真的是很酷的项目。

Yep, you can. Check ASE

Edit: Ok, after comments: I haven’t read the question properly. No you can’t write write proper, full fledged apps for Android, but anyway check ASE. It is really cool project.


无法显示HTML字符串

问题:无法显示HTML字符串

我正在Android WebView中使用显示字符串HTML挣扎。

在服务器端,我下载了一个网页并转义了HTML字符和引号(我使用了Python):

my_string = html.escape(my_string, True)

在Android客户端上:字符串不通过以下方式转义:

myString = StringEscapeUtils.unescapeHtml4(myString)
webview.loadData( myString, "text/html", "encoding");

但是,webview只是将它们显示为文字字符串。结果如下:

编辑:我添加从服务器端返回的原始字符串:

链接rel =“ apple-touch-icon”;尺寸=“ 114×114” href =“&quot; /static/favicon/apple-touch-icon-114×114.png”&gt; &lt; link rel =“苹果触摸图标”;尺寸=“ 72×72” href =“&quot; /static/favicon/apple-touch-icon-72×72.png”&gt; &lt; link rel =“苹果触摸图标”;尺寸=“ 144×144” href =“&quot; /static/favicon/apple-touch-icon-144×144.png”&gt; &lt; link rel =“苹果触摸图标”;尺寸=“ 60×60” href =“&quot; /static/favicon/apple-touch-icon-60×60.png”&gt; &lt; link rel =“苹果触摸图标”;尺寸=“ 120×120” href =“&quot; /static/favicon/apple-touch-icon-120×120.png”&gt; &lt; link rel =&quot; 苹果触摸图标” 尺寸=“ 76×76” href =“&quot; /static/favicon/apple-touch-icon-76×76.png”&gt; &lt; link rel =“苹果触摸图标”;尺寸=“ 152×152” href =“&quot; /static/favicon/apple-touch-icon-152×152.png”&gt; &lt; link rel =“苹果触摸图标”;尺寸=“ 180×180” href =“&quot; /static/favicon/apple-touch-icon-180×180.png”&gt; &lt; link rel =“ icon”;type =“ image / png” href =“&quot; /static/favicon/favicon-192×192.png” 尺寸=“ 192×192” &lt; link rel =“ icon”;type =“ image / png” href =“&quot; /static/favicon/favicon-160×160.png” 尺寸=“ 160×160” &lt; link rel =&quot; 图标” type =“ image / png” href =“&quot; /static/favicon/favicon-96×96.png” 尺寸=“ 96×96” &lt; link rel =“ icon”;type =“ image / png” href =“&quot; /static/favicon/favicon-16×16.png” 尺寸=“ 16×16” &lt; link rel =“ icon”;type =“ image / png” href =“&quot; /static/favicon/favicon-32×32.png” 尺寸=“ 32×32” &lt;元名称=“ msapplication-TileColor”;内容=“#da532c” &lt;元名称=“ msapplication-TileImage”;content =“ / static / favicon / mstile-144×144.png” &lt;元名称=“ msapplication-config”;内容=“ / static / favicon / browserconfig.xml”;&gt; &lt;!-外部CSS-&gt; &lt; link rel =“ stylesheet” href =&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css&quot; &lt;!-外部字体-&gt; &lt; link href =” // maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css” rel =“ stylesheet” &lt; link href =&#x27; // fonts.googleapis.com/css?family=Open+Sans:300,600′ rel =&#x27; stylesheet&#x27; type =&#x27; text / css&#x27;&gt; &lt; link href =&#x27; // fonts.googleapis.com/css?family=Lora:400,700′ rel =&#x27; stylesheet&#x27; type =&#x27; text / css&#x27;&gt; &lt;!-[如果是IE 9]&gt; &lt; script src =” // cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js”</script> &lt; script src =” // cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js”&lt; / script&gt; &lt ;! [endif]-&gt; &lt;!-网站CSS-&gt; &lt; link rel =“ stylesheet” type =“ text / css”;href =“&quot; /static/css/style.css”&gt; &lt; link rel =“ stylesheet” type =“ text / css”;href =“&quot; /static/css/glyphicon.css”&gt; &lt; / head&gt; &lt; body&gt; &lt; div class =“容器文章-页面”&gt; &lt; div class =“ row”&gt; &lt; div class =“ col-md-8 col-md-offset-2”&gt; &lt; h2&gt;&lt; a href =&quot; quot; href =“&quot; /static/css/glyphicon.css”&gt; &lt; / head&gt; &lt; body&gt; &lt; div class =“容器文章-页面”&gt; &lt; div class =“ row”&gt; &lt; div class =“ col-md-8 col-md-offset-2”&gt; &lt; h2&gt;&lt; a href =&quot; quot; href =“&quot; /static/css/glyphicon.css”&gt; &lt; / head&gt; &lt; body&gt; &lt; div class =“容器文章-页面”&gt; &lt; div class =“ row”&gt; &lt; div class =“ col-md-8 col-md-offset-2”&gt; &lt; h2&gt;&lt; a href =&quot;http://www.huffingtonpost.com/2015/03/22/ted-cruz-climate-change_n_6919002.html&quot;&gt ; Gov。杰里·布朗(Jerry Brown)说特德·克鲁兹(Ted Cruz)绝对不适合(&#39;)因气候变化而竞选公职的观点&lt; / a&lt; / h2&gt; &lt; h4&gt; Sam Levine&lt; / h4&gt; &lt; div class =“ article”&gt; 加利福尼亚州州长杰里·布朗(D)星期天说,德克萨斯州参议员特德·克鲁兹(R-Texas)“绝对不适合竞选公职”。因为他在气候变化方面的立场。&lt; p&gt;&quot;我刚从新罕布什尔州回来,那里到处都是冰雪。我对此的看法很简单:有关此事的辩论应遵循科学并应遵循数据,而且许多关于全球变暖的警报者,他们有一个问题,因为科学不支持他们。克鲁兹&lt; a href =&quot;https://www.youtube.com/watch?v=m0UJ_S​​c0Udk&lt ; said&lt; / a&gt; 在“与塞思·迈耶斯晚晚”上 &lt; / p&gt; &lt; p&gt;为了支持他的主张,克鲁兹引用了卫星数据,该数据显示在过去的17年中没有明显的变暖现象。但是Cruz的推理&lt; a href =&quot; http://www.politifact.com/truth-o-meter/statements/2015/mar/20 / ted-cruz / ted-cruzs-worlds-fire-not-last-17-years /“已被由Politifact揭穿,这表明科学家有足够的证据相信气候将继续变暖。&lt; p&gt;&quot;他所说的话绝对是错误的,“布朗在&lt; a href =&quot; http://www.nbcnews。 “不适合运行” n328046”“ NBC新闻”。他补充说&lt; a href =&quot; http://climate.nasa.gov/scientific-consensus/ “超过90%”。研究气候的科学家们一致认为,气候变化是人类活动造成的。“那个人象征着这种无知和对现有科学数据的直接伪造。令人震惊,我认为男人已经使自己完全不适合竞选公职。” 布朗说。&lt; p&gt;布朗补充说,气候变化具有&lt; a href =&quot; http://www.huffingtonpost.com/2015/03/06/california-drought-february- record_n_6820704.html?utm_hp_ref =加利福尼亚干旱“导致他所在州的干旱,以及东海岸的严寒和暴风雨。&lt; p&gt;虽然克鲁兹可能在新罕布什尔州到处都看到冰雪,但数据显示该国实际上正在经历&lt; a href =&quot; http://www.huffingtonpost.com/2015/02/19/cold-weather- winter_n_6713104.html“&gt;比平均水平&lt; / a&gt; / p。&lt; p&gt;布朗对克鲁兹的批评发生在得克萨斯州参议员被宣布宣布&lt; a href =&quot; http://www.huffingtonpost.com/2015/03/22/ted-cruz-2016_n_6917824.html” 总统竞选&lt; / a&gt;。&lt; / p&gt; &lt; / div&gt; &lt; div class =“原始”&gt; &lt; a href =&quot;http://www.huffingtonpost.com/2015/03/22/ted-cruz-climate-change_n_6919002.html&lt; VIEW ORIGINAL&lt; / a&gt; &lt; / div&gt; &lt; / div&gt; &lt; / div&gt; &lt; / div&gt; &lt; script src =” // code.jquery.com/jquery-latest.js”</script &lt; script src =” / static / js / modal.js”&lt; / script &lt; script src =&quot; /static/js/bootbox.min.js”&lt; / script&gt; &lt; script src =” / static / js / site.js”&lt; / script &lt; script&gt; (function(i,s,o,g,r,a,m){i [&#x27; GoogleAnalyticsObject&#x27;] = r; i [r] = i [r] || function(){(i [ r] .q = i [r] .q || [])。push(arguments)},i [r] .l = 1 * new Date(); a = s.createElement(o),m = s。 getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a,m)})(窗口,文档,&#x27; script&#x27;,&#x27; //万维网。google-analytics.com/analytics.js’,’ga’); ga(&#x27; create&#x27;,&#x27; UA-56257533-1&#x27;,&#x27; auto&#x27;);ga(&#xsend&#x27 ;,&#x27; pageview&#x27;); &lt; / script&gt; &lt; / body&gt; &lt; / html&gt;”

I am struggling with display string HTML in Android WebView.

On the server side, I downloaded a web page and escape HTML characters and quotes (I used Python):

my_string = html.escape(my_string, True)

On the Android client side: strings are unescaped by:

myString = StringEscapeUtils.unescapeHtml4(myString)
webview.loadData( myString, "text/html", "encoding");

However webview just display them as literal strings. Here are the result:

Edit: I add original string returned from server side:

“&lt;!DOCTYPE html&gt; &lt;html lang=&quot;en&quot;&gt; &lt;head&gt; &lt;meta charset=&quot;utf-8&quot;&gt; &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt; &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt; &lt;meta name=&quot;description&quot; content=&quot;&quot;&gt; &lt;title&gt;Saulify&lt;/title&gt; &lt;!– All the Favicons… –&gt; &lt;link rel=&quot;shortcut icon&quot; href=&quot;/static/favicon/favicon.ico&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;57×57&quot; href=&quot;/static/favicon/apple-touch-icon-57×57.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;114×114&quot; href=&quot;/static/favicon/apple-touch-icon-114×114.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;72×72&quot; href=&quot;/static/favicon/apple-touch-icon-72×72.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;144×144&quot; href=&quot;/static/favicon/apple-touch-icon-144×144.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;60×60&quot; href=&quot;/static/favicon/apple-touch-icon-60×60.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;120×120&quot; href=&quot;/static/favicon/apple-touch-icon-120×120.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;76×76&quot; href=&quot;/static/favicon/apple-touch-icon-76×76.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;152×152&quot; href=&quot;/static/favicon/apple-touch-icon-152×152.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;180×180&quot; href=&quot;/static/favicon/apple-touch-icon-180×180.png&quot;&gt; &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;/static/favicon/favicon-192×192.png&quot; sizes=&quot;192×192&quot;&gt; &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;/static/favicon/favicon-160×160.png&quot; sizes=&quot;160×160&quot;&gt; &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;/static/favicon/favicon-96×96.png&quot; sizes=&quot;96×96&quot;&gt; &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;/static/favicon/favicon-16×16.png&quot; sizes=&quot;16×16&quot;&gt; &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;/static/favicon/favicon-32×32.png&quot; sizes=&quot;32×32&quot;&gt; &lt;meta name=&quot;msapplication-TileColor&quot; content=&quot;#da532c&quot;&gt; &lt;meta name=&quot;msapplication-TileImage&quot; content=&quot;/static/favicon/mstile-144×144.png&quot;&gt; &lt;meta name=&quot;msapplication-config&quot; content=&quot;/static/favicon/browserconfig.xml&quot;&gt; &lt;!– External CSS –&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css&quot;&gt; &lt;!– External Fonts –&gt; &lt;link href=&quot;//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css&quot; rel=&quot;stylesheet&quot;&gt; &lt;link href=&#x27;//fonts.googleapis.com/css?family=Open+Sans:300,600&#x27; rel=&#x27;stylesheet&#x27; type=&#x27;text/css&#x27;&gt; &lt;link href=&#x27;//fonts.googleapis.com/css?family=Lora:400,700&#x27; rel=&#x27;stylesheet&#x27; type=&#x27;text/css&#x27;&gt; &lt;!–[if lt IE 9]&gt; &lt;script src=&quot;//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js&quot;&gt;&lt;/script&gt; &lt;script src=&quot;//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js&quot;&gt;&lt;/script&gt; &lt;![endif]–&gt; &lt;!– Site CSS –&gt; &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/static/css/style.css&quot;&gt; &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/static/css/glyphicon.css&quot;&gt; &lt;/head&gt; &lt;body&gt; &lt;div class=&quot;container article-page&quot;&gt; &lt;div class=&quot;row&quot;&gt; &lt;div class=&quot;col-md-8 col-md-offset-2&quot;&gt; &lt;h2&gt;&lt;a href=&quot;http://www.huffingtonpost.com/2015/03/22/ted-cruz-climate-change_n_6919002.html&quot;&gt;Gov. Jerry Brown Says Ted Cruz Is &amp;#39;Absolutely Unfit&amp;#39; To Run For Office Because Of Climate Change Views&lt;/a&gt;&lt;/h2&gt; &lt;h4&gt;Sam Levine&lt;/h4&gt; &lt;div class=&quot;article&quot;&gt; &lt;p&gt;California Gov. Jerry Brown (D) said on Sunday that Texas Sen. Ted Cruz (R-Texas) is &quot;absolutely unfit to be running for office&quot; because of his position on climate change.&lt;/p&gt; &lt;p&gt;&quot;I just came back from New Hampshire, where there&#x27;s snow and ice everywhere. My view on this is simple: Debates on this should follow science and should follow data, and many of the alarmists on global warming, they have a problem because the science doesn&#x27;t back them up,&quot; Cruz &lt;a href=&quot;https://www.youtube.com/watch?v=m0UJ_Sc0Udk&quot;&gt;said&lt;/a&gt; on &quot;Late Night with Seth Meyers&quot; last week.&lt;/p&gt; &lt;p&gt;To back up his claim, Cruz cited satellite data that has shown a lack of significant warming over the last 17 years. But Cruz&#x27;s reasoning &lt;a href=&quot;http://www.politifact.com/truth-o-meter/statements/2015/mar/20 /ted-cruz/ted-cruzs-worlds-fire-not-last-17-years/&quot;&gt;has been debunked by Politifact&lt;/a&gt;, which has shown that scientists have ample evidence to believe that the climate will continue to warm.&lt;/p&gt; &lt;p&gt;&quot;What he said is absolutely false,” Brown said on &lt;a href=&quot;http://www.nbcnews.com/meet-the-press/california-governor-ted-cruz- unfit-be-running-n328046&quot;&gt;NBC&#x27;s &quot;Meet the Press.&quot;&lt;/a&gt; He added that &lt;a href=&quot;http://climate.nasa.gov/scientific-consensus/&quot;&gt;over 90 percent&lt;/a&gt; of scientists who study the climate agree that climate change is caused by human activity. &quot;That man betokens such a level of ignorance and a direct falsification of existing scientific data. It&#x27;s shocking, and I think that man has rendered himself absolutely unfit to be running for office,&quot; Brown said.&lt;/p&gt; &lt;p&gt;Brown added that climate change has &lt;a href=&quot;http://www.huffingtonpost.com/2015/03/06/california-drought-february- record_n_6820704.html?utm_hp_ref=california-drought&quot;&gt;caused droughts in his state&lt;/a&gt;, as well as severe cold and storms on the east coast.&lt;/p&gt; &lt;p&gt;While Cruz may have seen snow and ice everywhere in New Hampshire, data shows that the country is actually experiencing a &lt;a href=&quot;http://www.huffingtonpost.com/2015/02/19/cold-weather- winter_n_6713104.html&quot;&gt;warmer than average&lt;/a&gt; winter.&lt;/p&gt; &lt;p&gt;Brown’s criticism of Cruz comes one day before the Texas senator is set to announce a &lt;a href=&quot;http://www.huffingtonpost.com/2015/03/22 /ted-cruz-2016_n_6917824.html&quot;&gt;presidential campaign&lt;/a&gt;. &lt;/p&gt; &lt;/div&gt; &lt;div class=&quot;original&quot;&gt; &lt;a href=&quot;http://www.huffingtonpost.com/2015/03/22/ted-cruz-climate-change_n_6919002.html&quot;&gt;VIEW ORIGINAL&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;script src=&quot;//code.jquery.com/jquery-latest.js&quot;&gt;&lt;/script&gt; &lt;script src=&quot;/static/js/modal.js&quot;&gt;&lt;/script&gt; &lt;script src=&quot;/static/js/bootbox.min.js&quot;&gt;&lt;/script&gt; &lt;script src=&quot;/static/js/site.js&quot;&gt;&lt;/script&gt; &lt;script&gt; (function(i,s,o,g,r,a,m){i[&#x27;GoogleAnalyticsObject&#x27;]=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,&#x27;script&#x27;,&#x27;//www.google-analytics.com/analytics.js&#x27;,&#x27;ga&#x27;); ga(&#x27;create&#x27;, &#x27;UA-56257533-1&#x27;, &#x27;auto&#x27;); ga(&#x27;send&#x27;, &#x27;pageview&#x27;); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt;”


回答 0

我在这里修改了代码:

public class test extends Activity {
    private WebView wv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test);
        wv = (WebView) findViewById(R.id.wv);
        String s = "&lt;!DOCTYPE html&gt; &lt;html lang=&quot;en&quot;&gt; &lt;head&gt; &lt;meta charset=&quot;utf-8&quot;&gt; &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt; &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt; &lt;meta name=&quot;description&quot; content=&quot;&quot;&gt; &lt;title&gt;Saulify&lt;/title&gt; &lt;!-- All the Favicons... --&gt; &lt;link rel=&quot;shortcut icon&quot; href=&quot;/static/favicon/favicon.ico&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;57x57&quot; href=&quot;/static/favicon/apple-touch-icon-57x57.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;114x114&quot; href=&quot;/static/favicon/apple-touch-icon-114x114.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;72x72&quot; href=&quot;/static/favicon/apple-touch-icon-72x72.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;144x144&quot; href=&quot;/static/favicon/apple-touch-icon-144x144.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;60x60&quot; href=&quot;/static/favicon/apple-touch-icon-60x60.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;120x120&quot; href=&quot;/static/favicon/apple-touch-icon-120x120.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;76x76&quot; href=&quot;/static/favicon/apple-touch-icon-76x76.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;152x152&quot; href=&quot;/static/favicon/apple-touch-icon-152x152.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;180x180&quot; href=&quot;/static/favicon/apple-touch-icon-180x180.png&quot;&gt; &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;/static/favicon/favicon-192x192.png&quot; sizes=&quot;192x192&quot;&gt; &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;/static/favicon/favicon-160x160.png&quot; sizes=&quot;160x160&quot;&gt; &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;/static/favicon/favicon-96x96.png&quot; sizes=&quot;96x96&quot;&gt; &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;/static/favicon/favicon-16x16.png&quot; sizes=&quot;16x16&quot;&gt; &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;/static/favicon/favicon-32x32.png&quot; sizes=&quot;32x32&quot;&gt; &lt;meta name=&quot;msapplication-TileColor&quot; content=&quot;#da532c&quot;&gt; &lt;meta name=&quot;msapplication-TileImage&quot; content=&quot;/static/favicon/mstile-144x144.png&quot;&gt; &lt;meta name=&quot;msapplication-config&quot; content=&quot;/static/favicon/browserconfig.xml&quot;&gt; &lt;!-- External CSS --&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css&quot;&gt; &lt;!-- External Fonts --&gt; &lt;link href=&quot;//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css&quot; rel=&quot;stylesheet&quot;&gt; &lt;link href=&#x27;//fonts.googleapis.com/css?family=Open+Sans:300,600&#x27; rel=&#x27;stylesheet&#x27; type=&#x27;text/css&#x27;&gt; &lt;link href=&#x27;//fonts.googleapis.com/css?family=Lora:400,700&#x27; rel=&#x27;stylesheet&#x27; type=&#x27;text/css&#x27;&gt; &lt;!--[if lt IE 9]&gt; &lt;script src=&quot;//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js&quot;&gt;&lt;/script&gt; &lt;script src=&quot;//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js&quot;&gt;&lt;/script&gt; &lt;![endif]--&gt; &lt;!-- Site CSS --&gt; &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/static/css/style.css&quot;&gt; &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/static/css/glyphicon.css&quot;&gt; &lt;/head&gt; &lt;body&gt; &lt;div class=&quot;container article-page&quot;&gt; &lt;div class=&quot;row&quot;&gt; &lt;div class=&quot;col-md-8 col-md-offset-2&quot;&gt; &lt;h2&gt;&lt;a href=&quot;http://www.huffingtonpost.com/2015/03/22/ted-cruz-climate-change_n_6919002.html&quot;&gt;Gov. Jerry Brown Says Ted Cruz Is &amp;#39;Absolutely Unfit&amp;#39; To Run For Office Because Of Climate Change Views&lt;/a&gt;&lt;/h2&gt; &lt;h4&gt;Sam Levine&lt;/h4&gt; &lt;div class=&quot;article&quot;&gt; &lt;p&gt;California Gov. Jerry Brown (D) said on Sunday that Texas Sen. Ted Cruz (R-Texas) is &quot;absolutely unfit to be running for office&quot; because of his position on climate change.&lt;/p&gt; &lt;p&gt;&quot;I just came back from New Hampshire, where there&#x27;s snow and ice everywhere. My view on this is simple: Debates on this should follow science and should follow data, and many of the alarmists on global warming, they have a problem because the science doesn&#x27;t back them up,&quot; Cruz &lt;a href=&quot;https://www.youtube.com/watch?v=m0UJ_Sc0Udk&quot;&gt;said&lt;/a&gt; on &quot;Late Night with Seth Meyers&quot; last week.&lt;/p&gt; &lt;p&gt;To back up his claim, Cruz cited satellite data that has shown a lack of significant warming over the last 17 years. But Cruz&#x27;s reasoning &lt;a href=&quot;http://www.politifact.com/truth-o-meter/statements/2015/mar/20 /ted-cruz/ted-cruzs-worlds-fire-not-last-17-years/&quot;&gt;has been debunked by Politifact&lt;/a&gt;, which has shown that scientists have ample evidence to believe that the climate will continue to warm.&lt;/p&gt; &lt;p&gt;&quot;What he said is absolutely false,” Brown said on &lt;a href=&quot;http://www.nbcnews.com/meet-the-press/california-governor-ted-cruz- unfit-be-running-n328046&quot;&gt;NBC&#x27;s &quot;Meet the Press.&quot;&lt;/a&gt; He added that &lt;a href=&quot;http://climate.nasa.gov/scientific-consensus/&quot;&gt;over 90 percent&lt;/a&gt; of scientists who study the climate agree that climate change is caused by human activity. &quot;That man betokens such a level of ignorance and a direct falsification of existing scientific data. It&#x27;s shocking, and I think that man has rendered himself absolutely unfit to be running for office,&quot; Brown said.&lt;/p&gt; &lt;p&gt;Brown added that climate change has &lt;a href=&quot;http://www.huffingtonpost.com/2015/03/06/california-drought-february- record_n_6820704.html?utm_hp_ref=california-drought&quot;&gt;caused droughts in his state&lt;/a&gt;, as well as severe cold and storms on the east coast.&lt;/p&gt; &lt;p&gt;While Cruz may have seen snow and ice everywhere in New Hampshire, data shows that the country is actually experiencing a &lt;a href=&quot;http://www.huffingtonpost.com/2015/02/19/cold-weather- winter_n_6713104.html&quot;&gt;warmer than average&lt;/a&gt; winter.&lt;/p&gt; &lt;p&gt;Brown’s criticism of Cruz comes one day before the Texas senator is set to announce a &lt;a href=&quot;http://www.huffingtonpost.com/2015/03/22 /ted-cruz-2016_n_6917824.html&quot;&gt;presidential campaign&lt;/a&gt;. &lt;/p&gt; &lt;/div&gt; &lt;div class=&quot;original&quot;&gt; &lt;a href=&quot;http://www.huffingtonpost.com/2015/03/22/ted-cruz-climate-change_n_6919002.html&quot;&gt;VIEW ORIGINAL&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;script src=&quot;//code.jquery.com/jquery-latest.js&quot;&gt;&lt;/script&gt; &lt;script src=&quot;/static/js/modal.js&quot;&gt;&lt;/script&gt; &lt;script src=&quot;/static/js/bootbox.min.js&quot;&gt;&lt;/script&gt; &lt;script src=&quot;/static/js/site.js&quot;&gt;&lt;/script&gt; &lt;script&gt; (function(i,s,o,g,r,a,m){i[&#x27;GoogleAnalyticsObject&#x27;]=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,&#x27;script&#x27;,&#x27;//www.google-analytics.com/analytics.js&#x27;,&#x27;ga&#x27;); ga(&#x27;create&#x27;, &#x27;UA-56257533-1&#x27;, &#x27;auto&#x27;); ga(&#x27;send&#x27;, &#x27;pageview&#x27;); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt;";


        wv.loadData(stripHtml(s), "text/html", "UTF-8");

    }

    public String stripHtml(String html) {
        return Html.fromHtml(html).toString();
    }

}

I have modified the code here:

public class test extends Activity {
    private WebView wv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test);
        wv = (WebView) findViewById(R.id.wv);
        String s = "&lt;!DOCTYPE html&gt; &lt;html lang=&quot;en&quot;&gt; &lt;head&gt; &lt;meta charset=&quot;utf-8&quot;&gt; &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt; &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt; &lt;meta name=&quot;description&quot; content=&quot;&quot;&gt; &lt;title&gt;Saulify&lt;/title&gt; &lt;!-- All the Favicons... --&gt; &lt;link rel=&quot;shortcut icon&quot; href=&quot;/static/favicon/favicon.ico&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;57x57&quot; href=&quot;/static/favicon/apple-touch-icon-57x57.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;114x114&quot; href=&quot;/static/favicon/apple-touch-icon-114x114.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;72x72&quot; href=&quot;/static/favicon/apple-touch-icon-72x72.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;144x144&quot; href=&quot;/static/favicon/apple-touch-icon-144x144.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;60x60&quot; href=&quot;/static/favicon/apple-touch-icon-60x60.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;120x120&quot; href=&quot;/static/favicon/apple-touch-icon-120x120.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;76x76&quot; href=&quot;/static/favicon/apple-touch-icon-76x76.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;152x152&quot; href=&quot;/static/favicon/apple-touch-icon-152x152.png&quot;&gt; &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;180x180&quot; href=&quot;/static/favicon/apple-touch-icon-180x180.png&quot;&gt; &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;/static/favicon/favicon-192x192.png&quot; sizes=&quot;192x192&quot;&gt; &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;/static/favicon/favicon-160x160.png&quot; sizes=&quot;160x160&quot;&gt; &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;/static/favicon/favicon-96x96.png&quot; sizes=&quot;96x96&quot;&gt; &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;/static/favicon/favicon-16x16.png&quot; sizes=&quot;16x16&quot;&gt; &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;/static/favicon/favicon-32x32.png&quot; sizes=&quot;32x32&quot;&gt; &lt;meta name=&quot;msapplication-TileColor&quot; content=&quot;#da532c&quot;&gt; &lt;meta name=&quot;msapplication-TileImage&quot; content=&quot;/static/favicon/mstile-144x144.png&quot;&gt; &lt;meta name=&quot;msapplication-config&quot; content=&quot;/static/favicon/browserconfig.xml&quot;&gt; &lt;!-- External CSS --&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css&quot;&gt; &lt;!-- External Fonts --&gt; &lt;link href=&quot;//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css&quot; rel=&quot;stylesheet&quot;&gt; &lt;link href=&#x27;//fonts.googleapis.com/css?family=Open+Sans:300,600&#x27; rel=&#x27;stylesheet&#x27; type=&#x27;text/css&#x27;&gt; &lt;link href=&#x27;//fonts.googleapis.com/css?family=Lora:400,700&#x27; rel=&#x27;stylesheet&#x27; type=&#x27;text/css&#x27;&gt; &lt;!--[if lt IE 9]&gt; &lt;script src=&quot;//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js&quot;&gt;&lt;/script&gt; &lt;script src=&quot;//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js&quot;&gt;&lt;/script&gt; &lt;![endif]--&gt; &lt;!-- Site CSS --&gt; &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/static/css/style.css&quot;&gt; &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/static/css/glyphicon.css&quot;&gt; &lt;/head&gt; &lt;body&gt; &lt;div class=&quot;container article-page&quot;&gt; &lt;div class=&quot;row&quot;&gt; &lt;div class=&quot;col-md-8 col-md-offset-2&quot;&gt; &lt;h2&gt;&lt;a href=&quot;http://www.huffingtonpost.com/2015/03/22/ted-cruz-climate-change_n_6919002.html&quot;&gt;Gov. Jerry Brown Says Ted Cruz Is &amp;#39;Absolutely Unfit&amp;#39; To Run For Office Because Of Climate Change Views&lt;/a&gt;&lt;/h2&gt; &lt;h4&gt;Sam Levine&lt;/h4&gt; &lt;div class=&quot;article&quot;&gt; &lt;p&gt;California Gov. Jerry Brown (D) said on Sunday that Texas Sen. Ted Cruz (R-Texas) is &quot;absolutely unfit to be running for office&quot; because of his position on climate change.&lt;/p&gt; &lt;p&gt;&quot;I just came back from New Hampshire, where there&#x27;s snow and ice everywhere. My view on this is simple: Debates on this should follow science and should follow data, and many of the alarmists on global warming, they have a problem because the science doesn&#x27;t back them up,&quot; Cruz &lt;a href=&quot;https://www.youtube.com/watch?v=m0UJ_Sc0Udk&quot;&gt;said&lt;/a&gt; on &quot;Late Night with Seth Meyers&quot; last week.&lt;/p&gt; &lt;p&gt;To back up his claim, Cruz cited satellite data that has shown a lack of significant warming over the last 17 years. But Cruz&#x27;s reasoning &lt;a href=&quot;http://www.politifact.com/truth-o-meter/statements/2015/mar/20 /ted-cruz/ted-cruzs-worlds-fire-not-last-17-years/&quot;&gt;has been debunked by Politifact&lt;/a&gt;, which has shown that scientists have ample evidence to believe that the climate will continue to warm.&lt;/p&gt; &lt;p&gt;&quot;What he said is absolutely false,” Brown said on &lt;a href=&quot;http://www.nbcnews.com/meet-the-press/california-governor-ted-cruz- unfit-be-running-n328046&quot;&gt;NBC&#x27;s &quot;Meet the Press.&quot;&lt;/a&gt; He added that &lt;a href=&quot;http://climate.nasa.gov/scientific-consensus/&quot;&gt;over 90 percent&lt;/a&gt; of scientists who study the climate agree that climate change is caused by human activity. &quot;That man betokens such a level of ignorance and a direct falsification of existing scientific data. It&#x27;s shocking, and I think that man has rendered himself absolutely unfit to be running for office,&quot; Brown said.&lt;/p&gt; &lt;p&gt;Brown added that climate change has &lt;a href=&quot;http://www.huffingtonpost.com/2015/03/06/california-drought-february- record_n_6820704.html?utm_hp_ref=california-drought&quot;&gt;caused droughts in his state&lt;/a&gt;, as well as severe cold and storms on the east coast.&lt;/p&gt; &lt;p&gt;While Cruz may have seen snow and ice everywhere in New Hampshire, data shows that the country is actually experiencing a &lt;a href=&quot;http://www.huffingtonpost.com/2015/02/19/cold-weather- winter_n_6713104.html&quot;&gt;warmer than average&lt;/a&gt; winter.&lt;/p&gt; &lt;p&gt;Brown’s criticism of Cruz comes one day before the Texas senator is set to announce a &lt;a href=&quot;http://www.huffingtonpost.com/2015/03/22 /ted-cruz-2016_n_6917824.html&quot;&gt;presidential campaign&lt;/a&gt;. &lt;/p&gt; &lt;/div&gt; &lt;div class=&quot;original&quot;&gt; &lt;a href=&quot;http://www.huffingtonpost.com/2015/03/22/ted-cruz-climate-change_n_6919002.html&quot;&gt;VIEW ORIGINAL&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;script src=&quot;//code.jquery.com/jquery-latest.js&quot;&gt;&lt;/script&gt; &lt;script src=&quot;/static/js/modal.js&quot;&gt;&lt;/script&gt; &lt;script src=&quot;/static/js/bootbox.min.js&quot;&gt;&lt;/script&gt; &lt;script src=&quot;/static/js/site.js&quot;&gt;&lt;/script&gt; &lt;script&gt; (function(i,s,o,g,r,a,m){i[&#x27;GoogleAnalyticsObject&#x27;]=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,&#x27;script&#x27;,&#x27;//www.google-analytics.com/analytics.js&#x27;,&#x27;ga&#x27;); ga(&#x27;create&#x27;, &#x27;UA-56257533-1&#x27;, &#x27;auto&#x27;); ga(&#x27;send&#x27;, &#x27;pageview&#x27;); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt;";


        wv.loadData(stripHtml(s), "text/html", "UTF-8");

    }

    public String stripHtml(String html) {
        return Html.fromHtml(html).toString();
    }

}


回答 1

试试这个代码,

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N){
   yourtextview.setText(Html.fromHtml(yourstring,Html.FROM_HTML_MODE_LEGACY));
}
else {
   yourtextview.setText(Html.fromHtml(yourstring));
}

Try this code,

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N){
   yourtextview.setText(Html.fromHtml(yourstring,Html.FROM_HTML_MODE_LEGACY));
}
else {
   yourtextview.setText(Html.fromHtml(yourstring));
}

回答 2

试试这个:

wv = (WebView) findViewById(R.id.wv);
String s = "You HTML string";
wv.loadData(stripHtml(s), "text/html", "UTF-8");

public String stripHtml(String html) {
    return Html.fromHtml(html).toString();
}

Try this:

wv = (WebView) findViewById(R.id.wv);
String s = "You HTML string";
wv.loadData(stripHtml(s), "text/html", "UTF-8");

public String stripHtml(String html) {
    return Html.fromHtml(html).toString();
}

如何用python完全制作Android应用程序?[关闭]

问题:如何用python完全制作Android应用程序?[关闭]

我想开发一个(相当简单)的Android应用程序,可通过Play商店进行分发。我想在python中完全这样做。但是,在线研究并没有启发我:大多数评论要么已经过时(> 1岁,并且我认为从那时起可能会更好地集成python),要么他们谈论在android中运行python(例如here)。

因此,我正在寻找有关以下问题的信息:

  • 用python完全开发App是否可行-这样做的工具是什么?(例如,推荐Kivy吗?)
  • 如果是这样:最佳软件环境是什么?(我尝试使用Android Studio失败,但是找不到在其中运行python代码的方法。)

我对应用程序开发非常陌生,非常感谢在python中而不是在Jave等中进行此操作的所有线索,我尚不知道。

非常感谢您的提前帮助。

I would like to develop a (rather simple) android app to be distributed via Play Store. I would like to do so completely in python. However, the online research hasn’t quite enlightened me: most comments are either outdated (>1 year old, and I feel there might be better integration of python since then) or they talk about running python in android (e.g. here).

Therefore, I’m looking for information regarding the questions:

  • is it feasible to develop an App completely in python – and what are the tools to do so? (Is e.g. Kivy recommendable?)
  • if so: what are the best software environments to implement this? (I unsuccessfully tried using Android Studio but couldn’t figure out a way to run python code there.)

I’m quite new to app development and would highly appreciate any leads of doing this in python rather than in Jave etc., which I don’t know yet.

Many thanks for you help in advance.


回答 0

回答您的第一个问题:是的,用纯python开发一个android应用程序是可行的,为了实现这一目标,我建议您使用BeeWare,它只是一套python工具,可以很好地协同工作,使您能够开发python中的平台本机应用程序。

结帐这个视频由BeeWare的创造者,完美解释并演示了它的应用

这个怎么运作

Android的首选实现语言是Java-因此,如果您想用Python编写Android应用程序,则需要一种在Java虚拟机上运行Python代码的方法。这就是VOC所做的。VOC是一个编译器-它获取Python源代码,将其编译为CPython字节码,然后将该字节码转换为与Java兼容的字节码。最终结果是将您的Python源代码文件直接编译为Java .class文件,然后可以将其打包到Android应用程序中。

VOC还允许您像访问Python对象一样访问本机Java对象,使用Python类实现Java接口,以及使用Python类实现Java类的子类。使用此功能,您可以直接针对本机Android API编写Android应用程序。

编写本机Android应用程序后,您可以使用“ 公文包”将Python代码打包为Android应用程序。

公文包是用于将Python项目转换为独立的本机应用程序的工具。您可以将项目打包为:

  • 苹果电脑
  • 视窗
  • 的Linux
  • iPhone / iPad
  • 安卓系统
  • 苹果电视
  • 电视操作系统。

您可以使用BeeWare套件检查用Python编写的本机Android Tic Tac Toe应用程序。在GitHub上

除BeeWare工具外,您还需要安装JDK和Android SDK来测试您的应用程序的运行。

并回答您的第二个问题:好的环境可以是任何您喜欢的东西,无论是文本编辑器,命令行还是IDE,如果您正在寻找好的python IDE,我建议您尝试Pycharm,它具有一个免费的社区版本,由于它是同一家公司生产的,因此它的环境与android studio类似。

我希望这是有帮助的

To answer your first question: yes it is feasible to develop an android application in pure python, in order to achieve this I suggest you use BeeWare, which is just a suite of python tools, that work together very well and they enable you to develop platform native applications in python.

checkout this video by the creator of BeeWare that perfectly explains and demonstrates it’s application

How it works

Android’s preferred language of implementation is Java – so if you want to write an Android application in Python, you need to have a way to run your Python code on a Java Virtual Machine. This is what VOC does. VOC is a transpiler – it takes Python source code, compiles it to CPython Bytecode, and then transpiles that bytecode into Java-compatible bytecode. The end result is that your Python source code files are compiled directly to a Java .class file, which can be packaged into an Android application.

VOC also allows you to access native Java objects as if they were Python objects, implement Java interfaces with Python classes, and subclass Java classes with Python classes. Using this, you can write an Android application directly against the native Android APIs.

Once you’ve written your native Android application, you can use Briefcase to package your Python code as an Android application.

Briefcase is a tool for converting a Python project into a standalone native application. You can package projects for:

  • Mac
  • Windows
  • Linux
  • iPhone/iPad
  • Android
  • AppleTV
  • tvOS.

You can check This native Android Tic Tac Toe app written in Python, using the BeeWare suite. on GitHub

in addition to the BeeWare tools, you’ll need to have a JDK and Android SDK installed to test run your application.

and to answer your second question: a good environment can be anything you are comfortable with be it a text editor and a command line, or an IDE, if you’re looking for a good python IDE I would suggest you try Pycharm, it has a community edition which is free, and it has a similar environment as android studio, due to to the fact that were made by the same company.

I hope this has been helpful


回答 1

您可以尝试BeeWare-如其网站上所述:

使用Python编写应用程序,然后使用丰富的本机用户界面在iOS,Android,Windows,MacOS,Linux,Web和tvOS上发布它们。一个代码库。多个应用程序。

提供您想要现在就用Python编写Android Apps的优点,并且具有以下优点:如果您最终也想在其他列出的平台上做某事,则将来无需学习其他框架。

这是Android Apps教程

You could try BeeWare – as described on their website:

Write your apps in Python and release them on iOS, Android, Windows, MacOS, Linux, Web, and tvOS using rich, native user interfaces. One codebase. Multiple apps.

Gives you want you want now to write Android Apps in Python, plus has the advantage that you won’t need to learn yet another framework in future if you end up also wanting to do something on one of the other listed platforms.

Here’s the Tutorial for Android Apps.


回答 2

Android上有两个主要的python应用程序竞争者

Chaquopy

https://chaquo.com/chaquopy/

它与Android构建系统集成,为所有android功能提供了Python API。引用网站“完整的Android API和用户界面工具包直接供您使用”。

Beeware(Toga小部件工具包)

https://pybee.org/

这提供了一个多目标编译器,支持许多目标,例如Android和iOS。它使用映射到主机接口调用的通用窗口小部件工具箱(toga)。

哪一个?

两者都是活跃项目,它们的github帐户显示了大量近期活动。

像所有小部件库一样,Beeware Toga也非常适合将基础知识扩展到多个平台。如果您具有基本的设计,并且希望扩展到其他平台,那么这应该对您来说很好。

另一方面,Chaquopy在将python API映射到Android方面更加精确。它还允许您混合使用Java,如果要使用其他资源中的现有代码,则很有用。如果您有严格的设计目标,并且主要想针对Android,那么这是一个更好的资源。

There are two primary contenders for python apps on Android

Chaquopy

https://chaquo.com/chaquopy/

This integrates with the Android build system, it provides a Python API for all android features. To quote the site “The complete Android API and user interface toolkit are directly at your disposal.”

Beeware (Toga widget toolkit)

https://pybee.org/

This provides a multi target transpiler, supports many targets such as Android and iOS. It uses a generic widget toolkit (toga) that maps to the host interface calls.

Which One?

Both are active projects and their github accounts shows a fair amount of recent activity.

Beeware Toga like all widget libraries is good for getting the basics out to multiple platforms. If you have basic designs, and a desire to expand to other platforms this should work out well for you.

On the other hand, Chaquopy is a much more precise in its mapping of the python API to Android. It also allows you to mix in Java, useful if you want to use existing code from other resources. If you have strict design targets, and predominantly want to target Android this is a much better resource.


回答 3

Android,Python!

当我在您的问题中同时看到这两个关键字时,我最先想到的是Kivy

在使用Android Studio进行Java原生Android开发之前,我曾尝试过Kivy。太棒了。这是我可以发现的一些优点。


使用简单

有了python基础知识,您就可以轻松学习它。


良好的社区

它有据可查,拥有一个活跃的社区。


跨平台。

您可以使用此单一框架为Android,iOS,Windows,Linux甚至Raspberry Pi开发东西。开源。


它是一个免费软件

如果您想要商业许可证,那么至少(跨平台)竞争者都希望您付费。


加速图形支持

Kivy的图形引擎基于OpenGL ES 2构建,使其适用于需要快速图形渲染的软件,例如游戏。



现在进入问题的下一部分,您不能将Android Studio IDE用于Kivy。是设置开发环境的详细指南。

Android, Python !

When I saw these two keywords together in your question, Kivy is the one which came to my mind first.

Before coming to native Android development in Java using Android Studio, I had tried Kivy. It just awesome. Here are a few advantage I could find out.


Simple to use

With a python basics, you won’t have trouble learning it.


Good community

It’s well documented and has a great, active community.


Cross platform.

You can develop thing for Android, iOS, Windows, Linux and even Raspberry Pi with this single framework. Open source.


It is a free software

At least few of it’s (Cross platform) competitors want you to pay a fee if you want a commercial license.


Accelerated graphics support

Kivy‘s graphics engine build over OpenGL ES 2 makes it suitable for softwares which require fast graphics rendering such as games.



Now coming into the next part of question, you can’t use Android Studio IDE for Kivy. Here is a detailed guide for setting up the development environment.


Assimp 导入和导出各种3D模型格式的库

打开资源导入库(ASSIMP)

用于导入和导出各种3D模型格式的库,包括生成缺失渲染数据的场景后处理

当前项目状态










提供了面向C和C++的API。有到其他语言(C#、Java、Python、Delphi、D)的各种绑定。Assimp也可以在Android和iOS上运行。此外,assimp还具有各种网格后处理工具:法线和切线空间生成、三角剖分、顶点缓存局部性优化、移除退化的基本体和重复顶点、按基本体类型排序、合并冗余材质等等

最新单据的

请在以下地址查阅最新文件:Asset-Importer-Lib-Doc

参与进来吧

这是包含最新功能和错误修复的开发资源库。不过,为了更有效地使用,我们建议使用可从以下网址获得的稳定版本之一Github Assimp Releases
你在文档里发现窃听器了吗?使用Doc-Repo
请同时查看我们的维基:https://github.com/assimp/assimp/wiki

如果您想查看我们的模型数据库,请使用以下回购:https://github.com/assimp/assimp-mdb

支持的文件格式

您可以找到支持的文件格式的完整列表here

大楼

让我们来看看https://github.com/assimp/assimp/blob/master/Build.md文件。我们在vcpkg中可用,并且我们的构建系统是CMake;如果您以前使用过CMake,那么您很有可能知道要做什么

端口

其他工具

open3mod是基于Assimp的导入和导出功能的功能强大的3D模型查看器

存储库结构

Open Asset Import Library是用C++实现的。目录结构如下所示:

/code		Source code
/contrib	Third-party libraries
/doc		Documentation (doxysource and pre-compiled docs)
/include	Public header C and C++ header files
/scripts 	Scripts used to generate the loading code for some formats
/port		Ports to other languages and scripts to maintain those.
/test		Unit- and regression tests, test suite of models
/tools		Tools (old assimp viewer, command line `assimp`)
/samples	A small number of samples to illustrate possible
                    use cases for Assimp

源代码的组织方式如下:

code/Common			The base implementation for importers and the infrastructure
code/PostProcessing		The post-processing steps
code/AssetLib/<FormatName>	Implementation for import and export for the format

从哪里获得帮助

有关更多信息,请访问our website或查看./doc-文件夹,包含HTML格式的官方文档。(适用于Windows的CHM包含在某些版本包中,应位于此处的根文件夹中)

如果医生不能解决你的问题,那就问吧StackOverflow with the assimp-tag如果您认为您发现了错误,请在Github上打开一个问题

开放式资源导入库是一个库,用于将各种3D文件格式加载到共享的内存格式中。它支持的不只是40种文件格式用于导入,以及越来越多的文件格式可供选择用于导出

我们还有一个Gitter频道:Gitter

贡献

我们高度赞赏对ASSIMP的贡献。参与进来的最简单方式是提交一个拉取请求,其中包含您对主存储库的master分支机构

贡献者

代码贡献者

这个项目的存在要归功于所有做出贡献的人。[Contribute]

财政捐赠者

成为一名财政捐赠者,帮助我们维持我们的社区。[Contribute]

个人

组织机构

与您的组织一起支持此项目。您的徽标将在此处显示,并带有指向您的网站的链接。[Contribute]

许可证

我们的执照是基于修改后的,3-子句BSD-许可证

一个非正式的总结是:想做什么就做什么,但在您的产品中包含Assimp的许可文本-如果我们的代码不起作用,不要起诉我们。请注意,与LGPLed代码不同,您可以静态链接到Assimp。有关法律详细信息,请参阅LICENSE文件

为什么要取这个名字?

对不起,我们是德国人:-),没有以英语为母语的人

Python-for-android 将Python应用程序转换为Android APK

Python-for-Android

Python-for-Android是在Android上打包Python应用程序的工具。您可以创建自己的Python发行版,包括所需的模块和依赖项,并将其与您自己的代码捆绑在APK中

功能包括:

  • 不同的应用程序后端,包括Kivy、PySDL2和带有Python Web服务器的WebView
  • 自动支持大多数纯Python模块,并内置了对许多其他模块的支持,包括流行的依赖项,如Numpy和sqlalChemy
  • 多个架构目标,适用于在任何给定设备上优化的APK

有关文档和支持,请参阅:

文档

请遵循quickstart
instructions
安装并开始创建APK的步骤

快速说明:安装Python-for-Android,安装方式为:

pip install python-for-android

(对于开发分支:pip install git+https://github.com/kivy/python-for-android.git)

与安装配合使用的测试:

p4a --version

要构建任何实际的应用程序,设置Android SDK和NDKquickstart使用快速入门中的SDK/NDK API级别和NDK版本,其他API级别可能不起作用

全部安装完毕后,使用SDL2构建APK,例如:

p4a apk --requirements=kivy --private /home/username/devel/planewave_frozen/ --package=net.inclem.planewavessdl2 --name="planewavessdl2" --version=0.5 --bootstrap=sdl2

对于完整的指令和参数选项,看见the
documentation

支持

如果您需要帮助,可以在我们的邮件列表上寻求帮助:

我们还有#support Discord channel

贡献

我们喜欢提出请求和讨论新奇的想法。查看Kivy项目contribution guide并且可以随意改进python-for-android(适用于android的python)

看见our
documentation
有关Python-for-Android开发和发布模型的更多信息,请不要担心细节。您只需要提个拉流请求,我们会处理睡觉的

以下邮件列表和IRC频道专门用于讨论开发Kivy框架及其姊妹项目:

我们还有#dev Discord channel

许可证

Python-for-Android是根据麻省理工学院的许可条款发布的。请参考许可证文件

历史

2015年,这些工具进行了重写,以提供一个新的、更易于使用和扩展的界面。如果您想浏览旧的工具链,其状态记录在https://github.com/kivy/python-for-android/tree/old_toolchain

2018年最后一个季度,python的食谱发生了变化。python3的新配方(3.7.1)有一个新的构建系统,它应用于古老的python配方,允许我们将python2的版本号提升到2.7.15。这一更改统一了两个Python食谱的构建过程,并可能解决了多年来检测到的各种问题。这些统一的Python食谱需要一个最低目标API水平为21Android 5.0-棒棒糖如果您需要构建的API级别低于21,则应该使用旧版本的python-for-Android(<=0.7.1)

在2020年3月,我们不再支持创建使用Python2的应用程序。支持构建Python2的最新Python-for-Android版本是2019.10.6版

贡献者

这个项目的存在要归功于所有做出贡献的人。[Contribute]

支持者

感谢我们所有的支持者!🙏[Become a backer]

赞助商

通过成为赞助商来支持这个项目。您的徽标将在此处显示,并带有指向您的网站的链接。[Become a sponsor]










Buck-一个快速构建系统,鼓励在各种平台和语言上创建小的、可重用的模块

Buck是一个构建工具。要了解Buck可以为您做些什么,请查看以下地址的文档http://buck.build/

安装

由于Buck用于构建Buck,因此初始构建过程包括两个阶段:

1.克隆buck仓库,并用蚂蚁引导:
git clone --depth 1 https://github.com/facebook/buck.git
cd buck
ant

您必须使用Java8或11才能成功编译。如果您看到来自ANT的编译错误,请检查您的JAVA_HOME指向这些版本中的一个

2.使用buck的自举版本构建buck:
./bin/buck build --show-output buck
# output will contain something like
# //programs:buck buck-out/gen/programs/buck.pex
buck-out/gen/programs/buck.pex --help
预置的降压二进制文件

预置的BUCK二进制文件,适用于任何BUCKsha可从以下地址下载https://jitpack.io/com/github/facebook/buck/<sha>/buck-<sha>.pex第一次请求buck版本时,它是通过jitpack因此,该初始二进制文件可能需要几分钟时间才能可用。每个后续请求都将直接服务于构建的工件。此功能也适用于任何buck叉子,因此您可以https://jitpack.io/com/github/<github-user-or-org>/buck/<sha>/buck-<sha>.pex

对于为JDK 11构建的buck二进制文件,请将url的末尾修改为buck-<sha>-java11.pex

功能已弃用

Buck试图在其内部快速行动。但是,对于面向用户的功能(构建规则、命令行界面等),Buck团队尝试使用优雅的弃用过程。请注意,这通常仅适用于有文档记录的功能,或文档较少但似乎使用广泛的功能。这个过程是:

  • 在Github上会打开一个问题,建议哪些内容将被弃用,以及何时将其删除。对于已弃用的较大功能,可能会有一段时间默认为新设置,旧行为只能与配置更改一起使用
  • 向Buck提交更改,该更改将旧行为置于配置标志之后,并将缺省值设置为旧行为。这些标志可在以下位置找到https://buck.build/concept/buckconfig.html#incompatible
  • 对于较大的功能,最终会进行更改,将默认行为设置为新行为。例如,当Skylark成为默认的构建文件解析器时
  • 当到达删除日期时,将提交更改以删除该功能。此时,配置值仍将进行解析,但不会由Buck在内部使用

许可证

Apache License 2.0

有没有办法在Android上运行Python?

问题:有没有办法在Android上运行Python?

我们正在开发S60版本,该平台具有不错的Python API。

但是,关于Android上的Python尚无官方资料,但是由于Jython存在,有没有办法让蛇和机器人一起工作?

We are working on an S60 version and this platform has a nice Python API..

However, there is nothing official about Python on Android, but since Jython exists, is there a way to let the snake and the robot work together??


回答 0

一种方法是使用Kivy

开源Python库,用于快速开发利用创新用户界面的应用程序,例如多点触控应用程序。

Kivy可在Linux,Windows,OS X,Android和iOS上运行。您可以在所有受支持的平台上运行相同的[python]代码。

Kivy Showcase应用程序

One way is to use Kivy:

Open source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps.

Kivy runs on Linux, Windows, OS X, Android and iOS. You can run the same [python] code on all supported platforms.

Kivy Showcase app


回答 1

还有一个新的Android脚本环境(ASE / SL4A)项目。它看起来很棒,并且与本机Android组件集成在一起。

注意:不再处于“主动开发”之下,但是可能有一些分支。

There is also the new Android Scripting Environment (ASE/SL4A) project. It looks awesome, and it has some integration with native Android components.

Note: no longer under “active development”, but some forks may be.


回答 2

是! :Android脚本环境

一个例子通过马特·卡茨通过SL4A – “这是写在Python代码半年线条码扫描器:

import android
droid = android.Android()
code = droid.scanBarcode()
isbn = int(code['result']['SCAN_RESULT'])
url = "http://books.google.com?q=%d" % isbn
droid.startActivity('android.intent.action.VIEW', url)

Yes! : Android Scripting Environment

An example via Matt Cutts via SL4A — “here’s a barcode scanner written in six lines of Python code:

import android
droid = android.Android()
code = droid.scanBarcode()
isbn = int(code['result']['SCAN_RESULT'])
url = "http://books.google.com?q=%d" % isbn
droid.startActivity('android.intent.action.VIEW', url)

回答 3

适用于Android的Pygame子集

Pygame是适用于Python(在桌面上)的2D游戏引擎,在新程序员中很流行。AndroidPygame子集将自己描述为…

…将Pygame功能的子集移植到Android平台。该项目的目标是允许创建特定于Android的游戏,并简化游戏从类似PC的平台到Android的移植。

示例包括打包为APK的完整游戏,这很有趣。

Pygame Subset for Android

Pygame is a 2D game engine for Python (on desktop) that is popular with new programmers. The Pygame Subset for Android describes itself as…

…a port of a subset of Pygame functionality to the Android platform. The goal of the project is to allow the creation of Android-specific games, and to ease the porting of games from PC-like platforms to Android.

The examples include a complete game packaged as an APK, which is pretty interesting.


回答 4

交叉编译和Ignifuga

我的博客上有说明和补丁用于Android的Python 2.7.2交叉编译的。

我还开源了我的2D游戏引擎Ignifuga。它基于Python / SDL,并且可以为Android交叉编译。即使您不将它用于游戏,您也可能会从代码或构建器实用程序(以Tim 命名的Schafer ……知道谁)中得到有用的想法。

Cross-Compilation & Ignifuga

My blog has instructions and a patch for cross compiling Python 2.7.2 for Android.

I’ve also open sourced Ignifuga, my 2D Game Engine. It’s Python/SDL based, and it cross compiles for Android. Even if you don’t use it for games, you might get useful ideas from the code or builder utility (named Schafer, after Tim… you know who).


回答 5

Android脚本层

SL4A做您想要的。您可以轻松地将其从其站点直接安装到设备上,而无需root用户。

它支持多种语言。Python是最成熟的。默认情况下,它使用Python 2.6,但是您可以使用3.2端口。我已经将该端口用于Galaxy S2上的所有东西,并且工作正常。

API

SL4A android为每种支持的语言提供了其库的端口。该库通过单个Android对象提供了与基础Android API的接口。

from android import Android

droid = Android()
droid.ttsSpeak('hello world') # example using the text to speech facade

每种语言都有几乎相同的API。您甚至可以在webview中使用JavaScript API。

let droid = new Android();
droid.ttsSpeak("hello from js");

使用者介面

对于用户界面,您有三个选择:

  • 您可以通过API轻松使用通用的本机对话和菜单。这对于确认对话和其他基本用户输入很有用。
  • 您还可以从Python脚本中打开Web视图,然后将HTML5用作用户界面。当您使用Python中的Web视图时,可以在Web视图和生成它的Python进程之间来回传递消息。用户界面不会是本机的,但仍然是一个不错的选择。
  • 一些对Android本机用户界面的支持,但是我不确定它的运行情况如何;我只是从未使用过它。

您可以混合使用选项,因此您可以在主界面上拥有一个Web视图,并且仍然使用本机对话。

QPython的

有一个名为QPython的第三方项目。它建立在SL4A之上,并抛出了其他有用的东西。

QPython为您提供了一个更好的UI来管理安装,并包括一个小的触摸屏代码编辑器,一个Python Shell和一个用于程序包管理的PIP Shell。它们还具有Python 3端口。两种版本均可从Play商店免费获得。QPython还在Android项目(包括Kivy)上捆绑了来自大量Python的库,因此它不仅仅是SL4A。

请注意,QPython仍在开发SL4A的分支(尽管,说实话,没有太多)。SL4A的主要项目本身已经死了。

有用的链接

Scripting Layer for Android

SL4A does what you want. You can easily install it directly onto your device from their site, and do not need root.

It supports a range of languages. Python is the most mature. By default, it uses Python 2.6, but there is a 3.2 port you can use instead. I have used that port for all kinds of things on a Galaxy S2 and it worked fine.

API

SL4A provides a port of their android library for each supported language. The library provides an interface to the underlying Android API through a single Android object.

from android import Android

droid = Android()
droid.ttsSpeak('hello world') # example using the text to speech facade

Each language has pretty much the same API. You can even use the JavaScript API inside webviews.

let droid = new Android();
droid.ttsSpeak("hello from js");

User Interfaces

For user interfaces, you have three options:

  • You can easily use the generic, native dialogues and menus through the API. This is good for confirmation dialogues and other basic user inputs.
  • You can also open a webview from inside a Python script, then use HTML5 for the user interface. When you use webviews from Python, you can pass messages back and forth, between the webview and the Python process that spawned it. The UI will not be native, but it is still a good option to have.
  • There is some support for native Android user interfaces, but I am not sure how well it works; I just haven’t ever used it.

You can mix options, so you can have a webview for the main interface, and still use native dialogues.

QPython

There is a third party project named QPython. It builds on SL4A, and throws in some other useful stuff.

QPython gives you a nicer UI to manage your installation, and includes a little, touchscreen code editor, a Python shell, and a PIP shell for package management. They also have a Python 3 port. Both versions are available from the Play Store, free of charge. QPython also bundles libraries from a bunch of Python on Android projects, including Kivy, so it is not just SL4A.

Note that QPython still develop their fork of SL4A (though, not much to be honest). The main SL4A project itself is pretty much dead.

Useful Links


回答 6

作为一个Python的爱好者和Android程序员,我很伤心地说,这是不是一个很好的路要走。有两个问题:

一个问题是,Android开发工具不只是一种编程语言。许多Android图形涉及XML文件来配置显示,类似于HTML。内置的Java对象与此XML布局集成在一起,比编写代码从逻辑到位图要容易得多。

另一个问题是G1(以及不久的将来可能还有其他Android设备)的运行速度并不快。200 MHz处理器和RAM非常有限。即使是在Java中,如果要使应用程序完全流畅,也必须进行大量重写以避免创建更多对象。在移动设备上运行一段时间后,Python将变得太慢。

As a Python lover and Android programmer, I’m sad to say this is not a good way to go. There are two problems:

One problem is that there is a lot more than just a programming language to the Android development tools. A lot of the Android graphics involve XML files to configure the display, similar to HTML. The built-in java objects are integrated with this XML layout, and it’s a lot easier than writing your code to go from logic to bitmap.

The other problem is that the G1 (and probably other Android devices for the near future) are not that fast. 200 MHz processors and RAM is very limited. Even in Java, you have to do a decent amount of rewriting-to-avoid-more-object-creation if you want to make your app perfectly smooth. Python is going to be too slow for a while still on mobile devices.


回答 7

基维

我想补充一下@JohnMudd关于Kivy的文章。自从他描述这种情况以来已经有好几年了,而Kivy有了长足的发展。

我认为,Kivy的最大卖点是其跨平台兼容性。您可以使用任何桌面环境(Windows / * nix等)对所有内容进行编码和测试,然后将您的应用打包到一系列不同的平台上,包括Android,iOS,MacOS和Windows(尽管应用通常缺乏本机外观)。

使用Kivy自己的KV语言,您可以轻松编码和构建GUI界面(就像Java XML一样,但不是TextView等,KV拥有自己的ui.widgets的类似翻译功能),我认为这很容易采用。

当前,最推荐使用Buildozerpython-for-android工具来构建和打包应用程序。我对它们都进行了尝试,可以肯定地说,它们使使用Python构建Android应用程序变得轻而易举。他们的指南也有据可查。

iOS是Kivy的另一个大卖点。您可以使用相同的代码库,通过kivy-ios Homebrew工具进行少量更改,尽管构建需要Xcode,但在其设备上运行之前(AFAIK,Xcode中的iOS Simulator当前不适用于x86体系结构构建) 。为了成功构建,还必须手动在Xcode中解决一些依赖项问题,并加以解决,但这并不太容易解决,并且Kivy Google Group的人员也非常有帮助。

综上所述,具有良好Python知识的用户应该不会有任何问题,很快就能掌握基础知识。

如果将Kivy用于更重要的项目,则可能会发现现有模块不令人满意。虽然有一些可行的解决方案。通过适用于Android的pyjniuspyobjus,用户现在可以访问Java / Objective-C类来控制某些本机API。

Kivy

I wanted to add to what @JohnMudd has written about Kivy. It has been years since the situation he described, and Kivy has evolved substantially.

The biggest selling point of Kivy, in my opinion, is its cross-platform compatibility. You can code and test everything using any desktop environment (Windows/*nix etc.), then package your app for a range of different platforms, including Android, iOS, MacOS and Windows (though apps often lack the native look and feel).

With Kivy’s own KV language, you can code and build the GUI interface easily (it’s just like Java XML, but rather than TextView etc., KV has its own ui.widgets for a similar translation), which is in my opinion quite easy to adopt.

Currently Buildozer and python-for-android are the most recommended tools to build and package your apps. I have tried them both and can firmly say that they make building Android apps with Python a breeze. Their guides are well documented too.

iOS is another big selling point of Kivy. You can use the same code base with few changes required via kivy-ios Homebrew tools, although Xcode is required for the build, before running on their devices (AFAIK the iOS Simulator in Xcode currently doesn’t work for the x86-architecture build). There are also some dependency issues which must be manually compiled and fiddled around with in Xcode to have a successful build, but they wouldn’t be too difficult to resolve and people in Kivy Google Group are really helpful too.

With all that being said, users with good Python knowledge should have no problem picking up the basics quickly.

If you are using Kivy for more serious projects, you may find existing modules unsatisfactory. There are some workable solutions though. With the (work in progress) pyjnius for Android, and pyobjus, users can now access Java/Objective-C classes to control some of the native APIs.


回答 8

Termux

您可以使用Termux应用程序(该程序为Android提供POSIX环境)来安装Python。

请注意,这apt install python将在Termux上安装Python3。对于Python2,您需要使用apt install python2

Termux

You can use the Termux app, which provides a POSIX environment for Android, to install Python.

Note that apt install python will install Python3 on Termux. For Python2, you need to use apt install python2.


回答 9

目前还没有,您很幸运能让Jython很快上班。如果您打算现在开始开发,那么最好还是坚持使用Java。

Not at the moment and you would be lucky to get Jython to work soon. If you’re planning to start your development now you would be better off with just sticking to Java for now on.


回答 10

使用SL4A(在其他答案中已经提到过),您可以运行成熟的web2py实例(其他python web框架也可能是候选对象)。SL4A不允许您执行本机UI组件(按钮,滚动条等),但它确实支持WebViews。WebView基本上只不过是指向固定地址的带状结构的Web浏览器。我相信本机Gmail应用程序使用WebView而非常规的窗口小部件路线。

这条路线将具有一些有趣的功能:

  • 对于大多数python网络框架,您实际上可以在不使用android设备或android模拟器的情况下进行开发和测试。
  • 无论您最终为手机编写的任何Python代码,也都可以进行很小的修改(如果有的话)放在公共Web服务器上。
  • 您可以利用那里所有疯狂的网络内容:查询,HTML5,CSS3等。

Using SL4A (which has already been mentioned by itself in other answers) you can run a full-blown web2py instance (other python web frameworks are likely candidates as well). SL4A doesn’t allow you to do native UI components (buttons, scroll bars, and the like), but it does support WebViews. A WebView is basically nothing more than a striped down web browser pointed at a fixed address. I believe the native Gmail app uses a WebView instead of going the regular widget route.

This route would have some interesting features:

  • In the case of most python web frameworks, you could actually develop and test without using an android device or android emulator.
  • Whatever Python code you end up writing for the phone could also be put on a public webserver with very little (if any) modification.
  • You could take advantage of all of the crazy web stuff out there: query, HTML5, CSS3, etc.

回答 11

QPython的

我使用QPython应用程序。它是免费的,包括代码编辑器,交互式解释器和程序包管理器,可让您直接在设备上创建和执行Python程序。

QPython

I use the QPython app. It’s free and includes a code editor, an interactive interpreter and a package manager, allowing you to create and execute Python programs directly on your device.


回答 12

适用于AndroidPython站点:

适用于Android的Python是一个用于创建自己的Python发行版(包括所需模块)并创建包含python,lib和应用程序的apk的项目。

From the Python for android site:

Python for android is a project to create your own Python distribution including the modules you want, and create an apk including python, libs, and your application.


回答 13

Chaquopy

Chaquopy是Android Studio基于Gradle的构建系统的插件。它着重于与标准Android开发工具的紧密集成

  • 它提供了完整的API,可以从Python调用Java从Java调用Python,从而允许开发人员使用最适合其应用程序每个组件的语言。

  • 它可以自动下载PyPI软件包并将其构建到应用程序中,包括选定的本机软件包,例如NumPy。

  • 它使您能够从Python完全访问所有Android API,包括本机用户界面工具包(纯Python活动示例)。

这是一种商业产品,但可免费用于开放源代码,并且将始终保持这种状态。

(我是这个产品的创造者。)

Chaquopy

Chaquopy is a plugin for Android Studio’s Gradle-based build system. It focuses on close integration with the standard Android development tools.

  • It provides complete APIs to call Java from Python or Python from Java, allowing the developer to use whichever language is best for each component of their app.

  • It can automatically download PyPI packages and build them into an app, including selected native packages such as NumPy.

  • It enables full access to all Android APIs from Python, including the native user interface toolkit (example pure-Python activity).

This is a commercial product, but it’s free for open-source use and will always remain that way.

(I am the creator of this product.)


回答 14

另一尝试:https : //code.google.com/p/android-python27/

这直接将Python解释器嵌入到您的应用apk中。

Yet another attempt: https://code.google.com/p/android-python27/

This one embed directly the Python interpretter in your app apk.


回答 15

是python官方网站上列出的一些工具


Playstore中有一个名为QPython3的应用程序,可用于编辑和运行python脚本。

Playstore连结


另一个名为Termux的应用程序,您可以在其中使用命令安装python

pkg install python

Playstore连结


如果您想开发应用程序,则可以使用Python Android脚本层(SL4A

The Scripting Layer for Android, SL4A, is an open source application that allows programs written in a range of interpreted languages to run on Android. It also provides a high level API that allows these programs to interact with the Android device, making it easy to do stuff like accessing sensor data, sending an SMS, rendering user interfaces and so on.


您还可以检查适用于Android的PySide,它实际上是Qt 4的Python绑定。


有一个称为PyMob的平台,其中的应用程序可以完全用Python编写,并且编译器工具流(PyMob)可以将它们转换为适用于各种平台的本机源代码。


同时检查python-for-android

python-for-android is an open source build tool to let you package Python code into standalone android APKs. These can be passed around, installed, or uploaded to marketplaces such as the Play Store just like any other Android app. This tool was originally developed for the Kivy cross-platform graphical framework, but now supports multiple bootstraps and can be easily extended to package other types of Python apps for Android.


试用适用 于Android的Chaquopy A Python SDK


Anddd … BeeWare

BeeWare allows you to write your app in Python and release it on multiple platforms. No need to rewrite the app in multiple programming languages. It means no issues with build tools, environments, compatibility, etc.

Here are some tools listed in official python website


There is an app called QPython3 in playstore which can be used for both editing and running python script.

Playstore link


Another app called Termux in which you can install python using command

pkg install python

Playstore Link


If you want develop apps , there is Python Android Scripting Layer (SL4A) .

The Scripting Layer for Android, SL4A, is an open source application that allows programs written in a range of interpreted languages to run on Android. It also provides a high level API that allows these programs to interact with the Android device, making it easy to do stuff like accessing sensor data, sending an SMS, rendering user interfaces and so on.


You can also check PySide for Android, which is actually Python bindings for the Qt 4.


There’s a platform called PyMob where apps can be written purely in Python and the compiler tool-flow (PyMob) converts them in native source codes for various platforms.


Also check python-for-android

python-for-android is an open source build tool to let you package Python code into standalone android APKs. These can be passed around, installed, or uploaded to marketplaces such as the Play Store just like any other Android app. This tool was originally developed for the Kivy cross-platform graphical framework, but now supports multiple bootstraps and can be easily extended to package other types of Python apps for Android.


Try Chaquopy A Python SDK for Android


Anddd… BeeWare

BeeWare allows you to write your app in Python and release it on multiple platforms. No need to rewrite the app in multiple programming languages. It means no issues with build tools, environments, compatibility, etc.


回答 16

您可以使用sl4a运行Python代码。sl4a支持Python,PerlJRubyLua,BeanShell,JavaScript,Tcl和Shell脚本。

您可以学习sl4a Python示例

You can run your Python code using sl4a. sl4a supports Python, Perl, JRuby, Lua, BeanShell, JavaScript, Tcl, and shell script.

You can learn sl4a Python Examples.


回答 17

您可以使用QPython

它具有Python控制台,编辑器以及程序包管理/安装程序

http://qpython.com/

这是一个具有Python 2和Python 3实现的开源项目。您可以直接从github下载源代码和Android .apk文件。

QPython 2:https//github.com/qpython-android/qpython/releases

QPython 3:https//github.com/qpython-android/qpython3/releases

You can use QPython:

It has a Python Console, Editor, as well as Package Management / Installers

http://qpython.com/

It’s an open source project with both Python 2 and Python 3 implementations. You can download the source and the Android .apk files directly from github.

QPython 2: https://github.com/qpython-android/qpython/releases

QPython 3: https://github.com/qpython-android/qpython3/releases


回答 18

如果您正在寻找3.4.2或3.5.1,则另一个选择是GitHub上的此存档。

Python3-Android 3.4.2 Python3-Android 3.5.1

目前,它支持Python 3.4.2或3.5.1以及NDK的10d版本。它还可以支持3.3和9c,11c和12

只需下载,运行make并获得.so或.a即可,这非常不错。

我目前使用它在Android设备上运行原始Python。通过对构建文件进行一些修改,您还可以将x86和armeabi制作为64位

Another option if you are looking for 3.4.2 or 3.5.1 is this archive on GitHub.

Python3-Android 3.4.2 or Python3-Android 3.5.1

It currently supports Python 3.4.2 or 3.5.1 and the 10d version of the NDK. It can also support 3.3 and 9c, 11c and 12

It’s nice in that you simply download it, run make and you get the .so or the .a

I currently use this to run raw Python on android devices. With a couple modifications to the build files you can also make x86 and armeabi 64 bit


回答 19

没有在此处看到此消息,但是由于Necessitas,Qt可以在Android上运行,因此您可以使用Pyside和Qt来做到这一点。

目前看来似乎很仓促,但最终可能是一条可行的路线…

http://qt-project.org/wiki/PySide_for_Android_guide

Didn’t see this posted here, but you can do it with Pyside and Qt now that Qt works on Android thanks to Necessitas.

It seems like quite a kludge at the moment but could be a viable route eventually…

http://qt-project.org/wiki/PySide_for_Android_guide


回答 20

pyqtdeploy似乎是一种选择,引用该文档是:

该工具与Qt随附的其他工具结合使用,可以部署用Python v2.7或Python v3.3或更高版本编写的PyQt4和PyQt5应用程序。它支持部署到桌面平台(Linux,Windows和OS X)以及移动平台(iOS和Android)。

根据通过pyqtdeploy和Qt5PyQt5应用程序部署到Android的说法,该应用程序是积极开发的,尽管很难找到有效的Android应用程序示例或关于如何将所有必需的库交叉编译到Android的教程。请记住,这是一个有趣的项目!

One more option seems to be pyqtdeploy which citing the docs is:

a tool that, in conjunction with other tools provided with Qt, enables the deployment of PyQt4 and PyQt5 applications written with Python v2.7 or Python v3.3 or later. It supports deployment to desktop platforms (Linux, Windows and OS X) and to mobile platforms (iOS and Android).

According to Deploying PyQt5 application to Android via pyqtdeploy and Qt5 it is actively developed, although it is difficult to find examples of working Android apps or tutorial on how to cross-compile all the required libraries to Android. It is an interesting project to keep in mind though!


回答 21

看一下BeeWare。在回答这个问题时,它仍处于早期开发中。目的是能够使用Python为所有受支持的操作系统(包括Android)创建本机应用程序。

Take a look at BeeWare. At the moment of answering this question it is still in early development. It’s aim is to be able to create native apps with Python for all supported operating systems, including Android.


回答 22

看看enaml-native,它采用了react-native概念并将其应用于python。

它允许用户使用本机Android小部件来构建应用,并提供API以使用来自python的android和java库。

它还与android-studio集成,并共享了react的一些不错的开发功能,例如代码重载和远程调试。

Check out enaml-native which takes the react-native concept and applies it to python.

It lets users build apps with native Android widgets and provides APIs to use android and java libraries from python.

It also integrates with android-studio and shares a few of react’s nice dev features like code reloading and remote debugging.


MMKV-微信开发的高效、小型的移动键值存储框架。适用于Android、iOS、MacOS、Windows和POSIX

MMKV是一种高效小的易于使用微信应用中使用的移动键值存储框架。它目前在以下位置可用安卓系统iOS/MacOSWin32POSIX

适用于Android的MMKV

功能

  • 高效MMKV使用mmap与文件保持内存同步,使用协议buf对值进行编码/解码,充分利用Android实现最佳性能
    • 多进程并发:MMKV支持进程间并发读写访问
  • 易于使用你可以边走边用MMKV。所有更改都会立即保存,否sync,否apply需要的呼叫数
  • 小的
    • 几个文件:MMKV包含进程锁、编码/解码助手和mmap逻辑等。真的很整洁
    • 二进制大小约为50K:MMKV在应用程序大小上为每个架构增加约50K,压缩后增加的更少(Apk)

快速入门

通过Maven安装

将以下行添加到build.gradle在您的应用程序模块上:

dependencies {
    implementation 'com.tencent:mmkv-static:1.2.10'
    // replace "1.2.10" with any available version
}

从1.2.8版本开始,MMKV已经已迁移到Maven Central旧版本(<=v1.2.7)仍可在JCenter上使用
有关其他安装选项,请参见Android Setup

快速教程

你可以边走边用MMKV。所有更改都会立即保存,否sync,否apply需要的呼叫数
在应用程序启动时设置MMKV,表示您的Application类中,添加以下行:

public void onCreate() {
    super.onCreate();

    String rootDir = MMKV.initialize(this);
    System.out.println("mmkv root: " + rootDir);
    //……
}

MMKV有一个全局实例,可以直接使用:

import com.tencent.mmkv.MMKV;
    
MMKV kv = MMKV.defaultMMKV();

kv.encode("bool", true);
boolean bValue = kv.decodeBool("bool");

kv.encode("int", Integer.MIN_VALUE);
int iValue = kv.decodeInt("int");

kv.encode("string", "Hello from mmkv");
String str = kv.decodeString("string");

MMKV还支持多进程访问完整的教程可在此处找到Android Tutorial

性能

随机写入int1000次之后,我们得到了这个图表:

有关更多基准数据,请参阅our benchmark

适用于iOS/MacOS的MMKV

功能

  • 高效MMKV使用mmap与文件保持内存同步,使用协议buf对值进行编码/解码,充分利用IOS/MacOS实现最佳性能
  • 易于使用你可以随时随地使用MMKV,不需要配置。所有更改都会立即保存,否synchronize需要的呼叫数
  • 小的
    • 几个文件:mmkv包含编码/解码助手和mmap逻辑,仅此而已。真的很整洁
    • 二进制大小小于30K:MMKV对每个架构的应用程序大小增加不到30K,压缩后(IPA)增加的更少

快速入门

通过CocoaPods安装:

  1. 安装CocoaPods
  2. 开放式终端,cd到您的项目目录,运行pod repo update使CocoaPods了解最新的MMKV版本;
  3. 编辑您的Podfile,添加pod 'MMKV'发送到您的应用程序目标;
  4. pod install
  5. 打开.xcworkspaceCocoaPods生成的文件;
  6. 添加#import <MMKV/MMKV.h>添加到您的源文件中,我们就完成了

有关其他安装选项,请参见iOS/macOS Setup

快速教程

你可以随时随地使用MMKV,不需要配置。所有更改都会立即保存,否synchronize需要打电话。在应用程序启动时设置MMKV,在您的-[MyApp application: didFinishLaunchingWithOptions:],添加以下行:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // init MMKV in the main thread
    [MMKV initializeMMKV:nil];

    //...
    return YES;
}

MMKV有一个全局实例,可以直接使用:

MMKV *mmkv = [MMKV defaultMMKV];
    
[mmkv setBool:YES forKey:@"bool"];
BOOL bValue = [mmkv getBoolForKey:@"bool"];
    
[mmkv setInt32:-1024 forKey:@"int32"];
int32_t iValue = [mmkv getInt32ForKey:@"int32"];
    
[mmkv setString:@"hello, mmkv" forKey:@"string"];
NSString *str = [mmkv getStringForKey:@"string"];

MMKV还支持多进程访问可以找到完整的教程here

性能

随机写入int对于10000次,我们得到了这个图表:

有关更多基准数据,请参阅our benchmark

适用于Win32的MMKV

功能

  • 高效MMKV使用mmap与文件保持内存同步,使用协议buf对值进行编码/解码,充分利用Windows实现最佳性能
    • 多进程并发:MMKV支持进程间并发读写访问
  • 易于使用你可以边走边用MMKV。所有更改都会立即保存,否save,否sync需要的呼叫数
  • 小的
    • 几个文件:MMKV包含进程锁、编码/解码助手和mmap逻辑等。真的很整洁
    • 二进制大小约为10K:MMKV增加了大约10K的应用程序大小,而压缩后的应用程序大小要少得多

快速入门

通过源安装

  1. 从GIT存储库获取源代码:
    git clone https://github.com/Tencent/MMKV.git
    
  2. 添加Win32/MMKV/MMKV.vcxproj您的解决方案;
  3. 添加MMKV项目到项目的依赖项;
  4. 添加$(OutDir)include到您的项目的C/C++->General->Additional Include Directories
  5. 添加$(OutDir)到您的项目的Linker->General->Additional Library Directories
  6. 添加MMKV.lib到您的项目的Linker->Input->Additional Dependencies
  7. 添加#include <MMKV/MMKV.h>添加到您的源文件中,我们就完成了

注:

  1. MMKV是用MT/MTd默认情况下运行时。如果您的项目使用MD/MDd,您应该更改MMKV的设置以匹配您的项目(C/C++->Code Generation->Runtime Library),或反之亦然
  2. MMKV是用Visual Studio 2017开发的,更改Platform Toolset如果使用不同版本的Visual Studio

有关其他安装选项,请参见Win32 Setup

快速教程

你可以边走边用MMKV。所有更改都会立即保存,否sync,否save需要的呼叫数
在应用程序启动时设置MMKV,例如在您的main(),添加以下行:

#include <MMKV/MMKV.h>

int main() {
    std::wstring rootDir = getYourAppDocumentDir();
    MMKV::initializeMMKV(rootDir);
    //...
}

MMKV有一个全局实例,可以直接使用:

auto mmkv = MMKV::defaultMMKV();

mmkv->set(true, "bool");
std::cout << "bool = " << mmkv->getBool("bool") << std::endl;

mmkv->set(1024, "int32");
std::cout << "int32 = " << mmkv->getInt32("int32") << std::endl;

mmkv->set("Hello, MMKV for Win32", "string");
std::string result;
mmkv->getString("string", result);
std::cout << "string = " << result << std::endl;

MMKV还支持多进程访问完整的教程可在此处找到Win32 Tutorial

用于POSIX的MMKV

功能

  • 高效MMKV使用mmap来保持内存与文件的同步,使用protocol buf来编解码值,充分利用POSIX来实现最佳性能
    • 多进程并发:MMKV支持进程间并发读写访问
  • 易于使用你可以边走边用MMKV。所有更改都会立即保存,否save,否sync需要的呼叫数
  • 小的
    • 几个文件:MMKV包含进程锁、编码/解码助手和mmap逻辑等。真的很整洁
    • 二进制大小约为7K:MMKV增加了大约7K的应用程序大小,而压缩后的大小要少得多

快速入门

通过CMake安装

  1. 从GIT存储库获取源代码:
    git clone https://github.com/Tencent/MMKV.git
    
  2. 编辑您的CMakeLists.txt,添加以下行:
    add_subdirectory(mmkv/POSIX/src mmkv)
    target_link_libraries(MyApp
        mmkv)
  3. 添加#include "MMKV.h"添加到您的源文件中,我们就完成了

有关其他安装选项,请参见POSIX Setup

快速教程

你可以边走边用MMKV。所有更改都会立即保存,否sync,否save需要的呼叫数
在应用程序启动时设置MMKV,例如在您的main(),添加以下行:

#include "MMKV.h"

int main() {
    std::string rootDir = getYourAppDocumentDir();
    MMKV::initializeMMKV(rootDir);
    //...
}

MMKV有一个全局实例,可以直接使用:

auto mmkv = MMKV::defaultMMKV();

mmkv->set(true, "bool");
std::cout << "bool = " << mmkv->getBool("bool") << std::endl;

mmkv->set(1024, "int32");
std::cout << "int32 = " << mmkv->getInt32("int32") << std::endl;

mmkv->set("Hello, MMKV for Win32", "string");
std::string result;
mmkv->getString("string", result);
std::cout << "string = " << result << std::endl;

MMKV还支持多进程访问完整的教程可在此处找到POSIX Tutorial

许可证

MMKV是在BSD 3条款许可下发布的。有关详细信息,请查看LICENSE.TXT

更改日志

请查看CHANGELOG.md有关更改历史的详细信息,请参阅

贡献

如果您对贡献感兴趣,请查看CONTRIBUTING.md,也加入我们的Tencent OpenSource Plan

为了明确对我们的成员的期望,MMKV通过了被广泛使用的贡献者公约定义的行为准则。我们认为它很好地表达了我们的价值观。有关更多信息,请查看Code of Conduct

常见问题和反馈

请查看FAQ第一。如果有任何问题,请不要犹豫issues

Kivy-用Python编写的开源UI框架,运行在Windows、Linux、MacOS、Android和iOS上

Kivy

创新的用户界面变得轻松

Kivy是一个开源的、跨平台的Python用于开发利用创新的多点触控用户界面的应用程序的框架。其目的是允许快速简单的交互设计和快速原型设计,同时使您的代码可重用和可部署

Kivy是用Python编写的,Cython,基于OpenGL ES 2,支持多种输入设备,具有丰富的微件库。使用相同的代码库,您可以针对Windows、MacOS、Linux、Android和iOS。所有Kivy小部件都支持多点触控

Kivy是麻省理工学院许可的,由一个伟大的社区积极开发,并得到由管理的许多项目的支持Kivy Organization

安装、文档和示例

详细的安装说明以及教程和一般文档(包括API参考)可在以下位置找到https://kivy.org/docs一个PDF version也是可用的

Kivy提供了许多示例,这些示例可以在examples文件夹

支持

如果您需要帮助,可以在我们的邮件列表上寻求帮助:

我们还有一个不和谐的频道:

贡献

我们喜欢提出请求和讨论新奇的想法。请查看我们的contribution guide你可以随意改进基维

以下邮件列表和不和谐频道专门用于讨论开发Kivy框架及其姊妹项目:

不和谐频道:

姊妹项目

  • Buildozer:Android和iOS通用Python打包程序
  • Plyer:平台相关API的平台无关Python包装器
  • Pyjnius:从Python动态访问Java/Android API
  • Pyobjus:从Python动态访问Objective-C/IOS API
  • Python for Android:用于为Android构建和打包Python应用程序的工具链
  • Kivy iOS:用于构建和打包适用于iOS的Kivy应用程序的工具链
  • Audiostream:用于直接访问麦克风和扬声器的库
  • KivEnt:面向Kivy的基于实体的游戏引擎
  • Garden:由用户创建和维护的小部件和库
  • Oscpy:OSC的一个快速且经过测试的python2/3实现

许可证

  • Kivy根据麻省理工学院的执照条款被释放。请参考许可证文件
  • 提供的字体Roboto和Roboto Mono根据Apache License, Version 2.0可以查看DejaVuSans(用于虚拟键盘)许可证here
  • 当前的UI设计改编自Moblintouch主题的SVG,并根据LGPLv2.1

贡献者

这个项目的存在要归功于所有做出贡献的人。[Contribute]

支持者

感谢我们所有的支持者!🙏[Become a backer]

赞助商

通过成为赞助商来支持这个项目。您的徽标将在此处显示,并带有指向您的网站的链接。[Become a sponsor]










免费的计算机编程类中文书籍,欢迎投稿

免费的编程中文书籍索引

免费的编程中文书籍索引,欢迎投稿.

如果这个仓库对你有帮助,欢迎stars.

欢迎大家将珍藏已久的经典免费书籍共享出来,您可以:

https://github.com/justjavac/free-programming-books-zh_CN/graphs/contributors:贡献者名单

缩放比例

斯威夫特

返回目录

读书笔记及其它

参与交流

测试相关

目录

编译原理

置顶

函数式概念

操作系统

计算机图形学

智能系统

WEB服务器

分布式系统

版本控制

编译原理

编辑器

函数式概念

NoSQL

计算机图形学

PostgreSQL

网络服务器

MySQL

版本控制

管理和监控

编辑器

项目相关

NoSQL

设计模式

PostgreSQL

Web

MySQL

大数据

管理和监控

编程艺术

项目相关

其它

设计模式

Android

网络

APP

大数据

AWK

编程艺术

C/C++

其它

C#

安卓系统

Clojure

应用程序

CSS/HTML

AWK

Dart

C/C++

Elixir

C#

Erlang

封闭式

Fortran

CSS/HTML

Go

省道

Groovy

灵丹妙药

Haskell

二郎

iOS

Fortran

Java

JavaScript

Kotlin

时髦的

LaTeX

哈斯克尔

LISP

IOS

Lua

Java语言

OCaml

JavaScript

Perl

科特林

PHP

乳胶

Prolog

口齿不清

Python

路亚

R

OCaml

Ruby

Perl

Rust

PHP

Scala

序言

Shell

蟒蛇

Swift

R

读书笔记及其它