我想制作一个应用程序在运行Android操作系统的设备上运行此C代码,但我们不使用NDK或JNI [英] I want to make an app to run this C code on a device running android OS but we don't use NDK or JNI for this

查看:59
本文介绍了我想制作一个应用程序在运行Android操作系统的设备上运行此C代码,但我们不使用NDK或JNI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

描述:这是一个正常的c代码,只打印你好世界



#include< stdio.h>



int main(无效)

{

printf(Hello World \ n);

返回0;

}

app应该在TextView中显示c代码的输出



我试过的:



i am android的新功能所以我想知道我该怎么做.....请帮帮我这是我的大学任务。

Description : here is a normal c code that just print hello world

#include<stdio.h>

int main(void)
{
printf("Hello World\n");
return 0;
}
app should show output of the c code in a TextView

What I have tried:

i am New in android so i want to know how can i do this .....please help me this is my college assignment.

推荐答案

这并不像你想象的那么简单。

问题是Android设备应用程序通常用Java编写(或者用Xamarin编写C#所以你的第一个问题是找到一个在android上运行的C编译器,并生成在android上执行的代码。

快速谷歌显示有些可能存在: c编译器,适用于Android - Google搜索 [ ^ ]但有多少那些实际上运行在adroid设备而不是一个针对android的交叉编译器我不知道。他们有什么样的质量完全是另一个问题!



然后你如何强制生成的应用程序输出到另一个应用程序的特定控件,我我完全不确定...



我不建议尝试这样做:选择一种常用于目标的语言而不是选择一种语言你有一些熟悉并试图强迫它进入一个它不受支持的系统。对于Android,Java是常态,C#/ Xamarin看起来很不错。
That's not as simple as you probably think.
The problem is that Android device apps are normally coded in Java (or C# with Xamarin) so your first problem is finding a C compiler that runs on android, and produces code that executes on android as well.
A quick google shows that some might exist: c compiler for android - Google Search[^] but how many of those actually run on teh adroid device rather than being a cross compiler that targets android I don't know. What kind of quality they have is another question altogether!

And quite how you then force the resulting app to output into a specific control that is part of another app, I am not at all sure...

I wouldn't recommend trying to do this: pick a language that is in common use for the target instead of picking a language you have some familiarity with and trying to force it into a system it isn't well supported for. For Android, Java is the norm, with C# / Xamarin looking pretty good.


这篇关于我想制作一个应用程序在运行Android操作系统的设备上运行此C代码,但我们不使用NDK或JNI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆