在应用程序中嵌入一个雷达(从谷歌)应用程序

2023-09-07 10:48:25 作者:路还长别猖狂ゝ

我要实现我的应用程序雷达。它基本上是一个应用程序的地方就会把所需位置的点上根据用户当前位置的雷达,使用户可以对点定位,有点像在FPS游戏中的雷达。

I want to implement a radar in my app. It's basically an app where it will put a dot of the desired location on the radar based on the user's current location so the user can navigate towards the dot, kind of like the radars in FPS games.

我发现这个: HTTP: //$c$c.google.com/p/apps-for-android/source/browse/#git%2FRadar

问题是,它似乎是利用这个唯一的方法(我知道的方式)是将其安装作为一个单独的应用程序,并有主要的应用程序调用应用雷达活动。这意味着,将有两个项目和两个应用程序将用户的设备上安装。

The thing is, it seems that the only way (the way I know) to utilize this is to install it as a separate app and have to main app call the activities in Radar app. Meaning, there will be two projects and two apps will be installed on the user's device.

我试过两个项目连接在一起,并有两个包在一个项目。问题是,对于雷达应用中的R.java文件将无法在其自己的包中产生。我已经通过这个论坛的职位看,似乎没有人试图嵌入这个雷达到他们的应用程序呢。

I tried joining the two projects together, and have two packages in one project. The problem is, the R.java file for the Radar app won't generate in its own package. I have looked through the posts in this forum and it seems that no one has tried to embed this radar into their apps yet.

我曾尝试与AndroidManifest文件,但没有运气搞乱。

I have tried messing with the AndroidManifest file but no luck.

任何帮助将是AP preciated。谢谢!

Any help would be appreciated. Thanks!

推荐答案

我创建Eclipse的一个项目雷达,并将其设置(通过属性 - > android->设置为库项目)是一个库项目。然后,从上述第一个胎面指定的链接,我创建和复制/粘贴所有的java code,图形,String.xml和AndroidManifest.xml中在我的库项目的相应位置。然后我去我的'主'项目,并设定(通过属性 - > android->库添加库)的雷达项目是导入库。从那里,我可以轻松创建调用RadarActivity和目标坐标经过2个浮点值我的主要项目的意向。它运作良好,并显示在一个视图中的雷达时pressing触发的意图。按钮

I created a project 'Radar' in eclipse and set it (via properties->android->set as library project) to be a library project. Then from the link specified in the first tread above, I created and copy/pasted all the java code, drawables, String.xml and the AndroidManifest.xml to the corresponding location in my library project. Then I went to my 'main' project and set (via properties->android->library add library) the 'radar' project to be an imported library. From there on I could easily create an intent in my main project which calls RadarActivity and passes 2 float values as the destination coordinates. It works well and shows the radar in a view when pressing the button that triggers that intent.

我在我的主项目中的按钮,它启动RadarActivity如下:

I have a button in my 'main' project and it launches the RadarActivity as follows:

findViewById(R.id.btShowRadar).setOnClickListener(
    new OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(CarLocatorActivity.this, com.google.android.radar.RadarActivity.class);
            intent.putExtra("latitude", (float)getCarLattitude());
            intent.putExtra("longitude", (float)getCarLongitude());
            startActivity(intent);
        }
    }
);