Android layout android:聊天应用弹出视图
我正在开发聊天应用程序。我想在有人向这样的用户发送消息时显示弹出视图。 还有参考图片 有人知道它是如何工作的吗?它将显示在本机应用程序或其他应用程序中。请提供链接供我参考。我正在使用该服务进行web服务调用。因此,该服务将调用弹出视图Android layout android:聊天应用弹出视图,android-layout,Android Layout,我正在开发聊天应用程序。我想在有人向这样的用户发送消息时显示弹出视图。 还有参考图片 有人知道它是如何工作的吗?它将显示在本机应用程序或其他应用程序中。请提供链接供我参考。我正在使用该服务进行web服务调用。因此,该服务将调用弹出视图 谢谢。据我所知,您无法从服务中打开对话框。 但您有一个选项可以从服务中打开弹出窗口 1) 做一个弹出窗口的布局 2) 在此活动中创建并将布局设置为内容视图 3) 在舱单上你必须写下这个 <activity android:theme="@android:s
谢谢。据我所知,您无法从服务中打开对话框。 但您有一个选项可以从服务中打开弹出窗口 1) 做一个弹出窗口的布局 2) 在此活动中创建并将布局设置为内容视图 3) 在舱单上你必须写下这个
<activity android:theme="@android:style/Theme.Dialog">
现在,您可以将活动作为弹出窗口打开
编辑
1) Layout main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<EditText android:id="@+id/web"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
3) Manifest.xml文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.AutocompleteTextView" android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".CustomAutoComplete" android:label="@string/app_name">
</activity>
<activity android:name="test1">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="Test2" android:theme="@android:style/Theme.Dialog">
</activity>
<service android:name="MyService"></service>
</application>
</manifest>
这是我开始服务的活动
package com.example.AutocompleteTextView;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.webkit.WebView;
import android.widget.FrameLayout;
public class test1 extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
startService(new Intent(getApplicationContext(), MyService.class));
finish();
}
}
刚刚加上
android.permission.SYSTEM\u警报\u窗口
清单中的权限,现在我可以显示来自服务的警报。检查我是否为您的问题添加了演示文件代码完美且正常工作,但是否可以在不启动新活动的情况下显示对话框。实际上,就我而言,我正在开发一个sdk。我们的客户端应用程序将集成我们的sdk,我希望我的客户端生活更轻松,他们不必在清单中包含活动。@Gem您可以在您的案例中发送广播,您的客户端应用程序将接收事件并从他们的应用程序中显示对话框。希望这能起作用。在这里你需要识别..你的消息何时来..这样你就可以使用广播接收器类..这样你就可以弹出你的自定义对话框。自定义对话框链接:查看SDK中的ApiDemos项目-DialogActivity示例。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.AutocompleteTextView" android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".CustomAutoComplete" android:label="@string/app_name">
</activity>
<activity android:name="test1">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="Test2" android:theme="@android:style/Theme.Dialog">
</activity>
<service android:name="MyService"></service>
</application>
</manifest>
package com.example.AutocompleteTextView;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Service;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.IBinder;
public class MyService extends Service{
@Override
public void onCreate() {
super.onCreate();
}
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
Intent intent1 = new Intent(this, Test2.class);
intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent1);
}
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
}
package com.example.AutocompleteTextView;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.webkit.WebView;
import android.widget.FrameLayout;
public class test1 extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
startService(new Intent(getApplicationContext(), MyService.class));
finish();
}
}