2011-07-28 15 views
2

私はチャットアプリケーションを開発しています。これは、http://code.google.com/p/android-smspopup/のようなメッセージをユーザに送信したときにポップアップビューを表示します。 も、それはalso.please reference.Iのために私のリンクを提供するネイティブアプリケーションや他のアプリで表示されます?任意の1にそれがどのように動作するか任意のアイデアを絵https://market.android.com/details?id=com.blntsoft.emailpopupアンドロイド:チャットアプリのポップアップビュー

が参照されたWebサービスcalls.soのためのサービスを使用していますサービスがポップアップ表示を呼び出します。

ありがとうございます。

+0

ここでは、URのメッセージが表示される必要があります。ブロードキャストレシーバのクラスを使用すると、通知ポップアップのカスタムダイアログが表示されます。 カスタムダイアログのリンク:http://www.helloandroid.com/tutorials/how-display-custom-dialog-your-android-application – CoDe

+0

SDKのApiDemosプロジェクト、DialogActivityのサンプルをご覧ください。 –

答えて

10

私の知る限り、サービスからダイアログを開くことはできません。 サービスのポップアップウィンドウを開くためのオプションが1つあります

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

を追加したサービスを開始しています活動です

マニフェストの許可と今、私はalを表示することができますサービスからのert。

関連する問題