2011-07-28 4 views
2

채팅 응용 프로그램을 개발 중입니다. 일부 사용자가 http://code.google.com/p/android-smspopup/과 같은 메시지를 보낼 때 팝업보기를 표시하고 싶습니다. 도이 사진이 어떻게 작동하는지 어떤 생각이? 그것은 네이티브 응용 프로그램이나 다른 응용 프로그램에 표시됩니다 https://market.android.com/details?id=com.blntsoft.emailpopupandroid : 채팅 응용 프로그램 팝업보기

중 하나가 also.please 나에게 reference.I 웹 서비스 calls.so에 대한 서비스를 사용하고 있습니다에 대한 링크를 제공 참조 서비스가 팝업보기를 호출합니다.

감사합니다.

+0

여기에 당신이 indentify..when 메시지가 필요합니다. 그래서 그 방송 수신기 클래스를 사용하여 할 수 있습니다 .. 그래서 당신이 사용자 정의 대화 팝업 팝업있어. 사용자 정의 대화 상자에 대한 링크 : http : //www.helloandroid.com/tutorials/how-display-custom-dialog-your-android-application – CoDe

+0

SDK의 ApiDemos 프로젝트 - DialogActivity 샘플을 살펴보십시오. –

답변

10

제 지식으로는 서비스에서 대화 상자를 열 수 없습니다. 하지만 그 서비스에 대한 팝업 창을 열 수있는 옵션이 하나 있습니다.

1) 팝업 창의 레이아웃을 만듭니다.

2) 활동을 만들고 서비스에서)이

<activity android:theme="@android:style/Theme.Dialog"> 

4를 작성해야 매니페스트에서이 활동

3) 콘텐츠보기로 레이아웃 설정 당신이 때 당신이 활동을 호출해야 열 popup.But 서비스에서 당신이

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 

으로 의도의 플래그를 설정해야한다는 것이 마음을 유지하려면 이제 팝업 창으로 활동을 열 수 있습니다.

EDIT

1) 레이아웃 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> 

2) 팝업로서 작용할 것이다 test2.java는

package com.example.AutocompleteTextView; 

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 

public class Test2 extends Activity{ 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
    } 
} 

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> 

4) 서비스 MyService.java

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(); 

    } 
} 
+0

재생에 감사드립니다. 팝업을위한 작업 코드가 있습니까? –

+0

확인 난 문제에 대한 데모 파일을 추가했다. – Dharmendra

+0

코드를 사용해 주셔서 감사합니다. –

0

그냥

android.permission.SYSTEM_ALERT_WINDOW

추가 서비스를 시작하고있는 활동이다

매니페스트의 사용 권한을 이제 알 수 있습니다. 서비스에서 ert.

관련 문제